View difference between Paste ID: GTFmApbQ and 4cFVYu3v
SHOW: | | - or go back to the newest paste.
1
-------------------------------------------------------------------------------------------------------------------
2
if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
3
local Player,Mouse,mouse,UserInputService,ContextActionService = owner
4
do
5
    print("FE Compatibility code by Mokiros")
6
    script.Parent = Player.Character
7
 
8
    --RemoteEvent for communicating
9
    local Event = Instance.new("RemoteEvent")
10
    Event.Name = "UserInput_Event"
11
 
12
    --Fake event to make stuff like Mouse.KeyDown work
13
    local function fakeEvent()
14
        local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
15
        t.connect = t.Connect
16
        return t
17
    end
18
 
19
    --Creating fake input objects with fake variables
20
    local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
21
    local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
22
    local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
23
        CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
24
    end}
25
    --Merged 2 functions into one by checking amount of arguments
26
    CAS.UnbindAction = CAS.BindAction
27
 
28
    --This function will trigger the events that have been :Connect()'ed
29
    local function te(self,ev,...)
30
        local t = m[ev]
31
        if t and t._fakeEvent and t.Function then
32
            t.Function(...)
33
        end
34
    end
35
    m.TrigEvent = te
36
    UIS.TrigEvent = te
37
 
38
    Event.OnServerEvent:Connect(function(plr,io)
39
        if plr~=Player then return end
40
        if io.isMouse then
41
            m.Target = io.Target
42
            m.Hit = io.Hit
43
        else
44
            local b = io.UserInputState == Enum.UserInputState.Begin
45
            if io.UserInputType == Enum.UserInputType.MouseButton1 then
46
                return m:TrigEvent(b and "Button1Down" or "Button1Up")
47
            end
48
            for _,t in pairs(CAS.Actions) do
49
                for _,k in pairs(t.Keys) do
50
                    if k==io.KeyCode then
51
                        t.Function(t.Name,io.UserInputState,io)
52
                    end
53
                end
54
            end
55
            m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
56
            UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
57
        end
58
    end)
59
    Event.Parent = NLS([==[
60
    local Player = game:GetService("Players").LocalPlayer
61
    local Event = script:WaitForChild("UserInput_Event")
62
 
63
    local UIS = game:GetService("UserInputService")
64
    local input = function(io,a)
65
        if a then return end
66
        --Since InputObject is a client-side instance, we create and pass table instead
67
        Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
68
    end
69
    UIS.InputBegan:Connect(input)
70
    UIS.InputEnded:Connect(input)
71
 
72
    local Mouse = Player:GetMouse()
73
    local h,t
74
    --Give the server mouse data 30 times every second, but only if the values changed
75
    --If player is not moving their mouse, client won't fire events
76
    while wait(1/30) do
77
        if h~=Mouse.Hit or t~=Mouse.Target then
78
            h,t=Mouse.Hit,Mouse.Target
79
            Event:FireServer({isMouse=true,Target=t,Hit=h})
80
        end
81
    end]==],Player.Character)
82
    Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
83
end
84
-------------------------------------------------------------------------------------------------------------------
85
86
local fall = false
87
88
local fade = false
89
90
local delete = false
91
92
local clear = false
93
94
function faded(brick)
95
if brick and fade == true then
96
wait(0.5)
97
brick.Transparency = 0.1
98
wait(0.1)
99
brick.Transparency = 0.2
100
wait(0.1)
101
brick.Transparency = 0.3
102
wait(0.1)
103
brick.Transparency = 0.4
104
wait(0.1)
105
brick.Transparency = 0.5
106
wait(0.1)
107
brick.Transparency = 0.6
108
wait(0.1)
109
brick.Transparency = 0.7
110
wait(0.1)
111
brick.Transparency = 0.8
112
wait(0.1)
113
brick.Transparency = 0.9
114
wait(0.1)
115
brick.Transparency = 1
116
brick:Destroy()
117
end
118
end
119
120
Mouse.Button1Down:connect(function()
121
if Mouse.Target then
122
if clear == true then
123
for i,v in pairs(Mouse.Target.Parent:GetChildren()) do
124
if v.ClassName == "CharacterMesh" or v.ClassName == "Shirt" or v.ClassName == "ShirtGraphic" or v.ClassName == "Pants" then
125
v:Destroy()
126
end
127
end
128
for i,v in pairs(Mouse.Target:GetChildren()) do
129
if v.ClassName ~= "Motor6D" and v.ClassName ~= "Weld" and v.ClassName ~= "Motor" and v.ClassName ~= "Attachment" then
130
v:Destroy()
131
end
132
end
133
end
134
if clear == false then
135
if delete == false then
136
local br = Instance.new("Part",workspace)
137
br.Size = Vector3.new(2,2,2)
138
br.Anchored = true
139
br.Position = Mouse.Hit.p + Vector3.new(0,1,0)
140
br.BrickColor = BrickColor.new("Really blue")
141
br.BottomSurface = Enum.SurfaceType.Smooth
142
br.TopSurface = Enum.SurfaceType.Smooth
143
if fall == true then
144
br.Anchored = false
145
end
146
if fade == true then
147
faded(br)
148
end
149
else
150
if Mouse.Target.Name ~= "Base" and Mouse.Target.Name ~= "Baseplate" then
151
Mouse.Target:Destroy()
152
end
153
end
154
end
155
end
156
end)
157
158
Mouse.KeyDown:connect(function(k)
159
k = k:lower()
160
if k=='z' then
161
fall = not fall
162
elseif k=='x' then
163
fade = not fade
164
elseif k=='q' then
165
delete = not delete
166
elseif k=='e' then
167
clear = not clear
168
end
169
end)