View difference between Paste ID: 6RbCpEBK and 3u1aRf0U
SHOW: | | - or go back to the newest paste.
1
if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
2
local Player,game,owner = owner,game
3
local RealPlayer = Player
4
do
5
    print("FE Compatibility code V2 by Mokiros")
6
    local RealPlayer = RealPlayer
7
    script.Parent = RealPlayer.Character
8
 
9
    --Fake event to make stuff like Mouse.KeyDown work
10
    local Disconnect_Function = function(this)
11
        this[1].Functions[this[2]] = nil
12
    end
13
    local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
14
    local FakeEvent_Metatable = {__index={
15
        Connect = function(this,f)
16
            local i = tostring(math.random(0,10000))
17
            while this.Functions[i] do
18
                i = tostring(math.random(0,10000))
19
            end
20
            this.Functions[i] = f
21
            return setmetatable({this,i},Disconnect_Metatable)
22
        end
23
    }}
24
    FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
25
    local function fakeEvent()
26
        return setmetatable({Functions={}},FakeEvent_Metatable)
27
    end
28
 
29
    --Creating fake input objects with fake variables
30
    local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
31
    FakeMouse.keyUp = FakeMouse.KeyUp
32
    FakeMouse.keyDown = FakeMouse.KeyDown
33
    local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
34
    local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
35
        CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
36
    end}
37
    --Merged 2 functions into one by checking amount of arguments
38
    CAS.UnbindAction = CAS.BindAction
39
 
40
    --This function will trigger the events that have been :Connect()'ed
41
    local function TriggerEvent(self,ev,...)
42
        for _,f in pairs(self[ev].Functions) do
43
            f(...)
44
        end
45
    end
46
    FakeMouse.TriggerEvent = TriggerEvent
47
    UIS.TriggerEvent = TriggerEvent
48
 
49
    --Client communication
50
    local Event = Instance.new("RemoteEvent")
51
    Event.Name = "UserInput_Event"
52
    Event.OnServerEvent:Connect(function(plr,io)
53
        if plr~=RealPlayer then return end
54
        FakeMouse.Target = io.Target
55
        FakeMouse.Hit = io.Hit
56
        if not io.isMouse then
57
            local b = io.UserInputState == Enum.UserInputState.Begin
58
            if io.UserInputType == Enum.UserInputType.MouseButton1 then
59
                return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
60
            end
61
            if io.UserInputType == Enum.UserInputType.MouseButton2 then
62
                return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
63
            end
64
            for _,t in pairs(CAS.Actions) do
65
                for _,k in pairs(t.Keys) do
66
                    if k==io.KeyCode then
67
                        t.Function(t.Name,io.UserInputState,io)
68
                    end
69
                end
70
            end
71
            FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
72
            UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
73
        end
74
    end)
75
    Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
76
    local Mouse = owner:GetMouse()
77
    local UIS = game:GetService("UserInputService")
78
    local input = function(io,RobloxHandled)
79
        if RobloxHandled then return end
80
        --Since InputObject is a client-side instance, we create and pass table instead
81
        Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
82
    end
83
    UIS.InputBegan:Connect(input)
84
    UIS.InputEnded:Connect(input)
85
    local h,t
86
    --Give the server mouse data every second frame, but only if the values changed
87
    --If player is not moving their mouse, client won't fire events
88
    local HB = game:GetService("RunService").Heartbeat
89
    while true do
90
        if h~=Mouse.Hit or t~=Mouse.Target then
91
            h,t=Mouse.Hit,Mouse.Target
92
            Event:FireServer({isMouse=true,Target=t,Hit=h})
93
        end
94
        --Wait 2 frames
95
        for i=1,2 do
96
            HB:Wait()
97
        end
98
    end]==],script)
99
 
100
    ----Sandboxed game object that allows the usage of client-side methods and services
101
    --Real game object
102
    local RealGame = game
103
 
104
    --Metatable for fake service
105
    local FakeService_Metatable = {
106
        __index = function(self,k)
107
            local s = rawget(self,"_RealService")
108
            if s then
109
                return typeof(s[k])=="function"
110
                and function(_,...)return s[k](s,...)end or s[k]
111
            end
112
        end,
113
        __newindex = function(self,k,v)
114
            local s = rawget(self,"_RealService")
115
            if s then s[k]=v end
116
        end
117
    }
118
    local function FakeService(t,RealService)
119
        t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
120
        return setmetatable(t,FakeService_Metatable)
121
    end
122
 
123
    --Fake game object
124
    local FakeGame = {
125
        GetService = function(self,s)
126
            return rawget(self,s) or RealGame:GetService(s)
127
        end,
128
        Players = FakeService({
129
            LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
130
        },"Players"),
131
        UserInputService = FakeService(UIS,"UserInputService"),
132
        ContextActionService = FakeService(CAS,"ContextActionService"),
133
        RunService = FakeService({
134
            _btrs = {},
135
            RenderStepped = RealGame:GetService("RunService").Heartbeat,
136
            BindToRenderStep = function(self,name,_,fun)
137
                self._btrs[name] = self.Heartbeat:Connect(fun)
138
            end,
139
            UnbindFromRenderStep = function(self,name)
140
                self._btrs[name]:Disconnect()
141
            end,
142
        },"RunService")
143
    }
144
    rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
145
    FakeGame.service = FakeGame.GetService
146
    FakeService(FakeGame,game)
147
    --Changing owner to fake player object to support owner:GetMouse()
148
    game,owner = FakeGame,FakeGame.Players.LocalPlayer
149
end
150
151
152
plr = owner
153
char = plr.Character
154
mouse = plr:GetMouse()
155
disabled = false
156
157
function round(n)
158
    return n % 1 >= 0.5 and math.ceil(n) or math.floor(n)
159
end
160
161
VT = Vector3.new
162
163
function placepiston()
164
if disabled == false then
165
	--Converted with ttyyuu12345's model to script plugin v4
166
function sandbox(var,func)
167
	local env = getfenv(func)
168
	local newenv = setmetatable({},{
169
		__index = function(self,k)
170
			if k=="script" then
171
				return var
172
			else
173
				return env[k]
174
			end
175
		end,
176
	})
177
	setfenv(func,newenv)
178
	return func
179
end
180
cors = {}
181
mas = Instance.new("Model",game:GetService("Lighting"))
182
Model0 = Instance.new("Model")
183
Part1 = Instance.new("Part")
184
Decal2 = Instance.new("Decal")
185
Decal3 = Instance.new("Decal")
186
Decal4 = Instance.new("Decal")
187
Decal5 = Instance.new("Decal")
188
Decal6 = Instance.new("Decal")
189
Decal7 = Instance.new("Decal")
190
Decal8 = Instance.new("Decal")
191
Weld9 = Instance.new("Weld")
192
Part10 = Instance.new("Part")
193
Decal11 = Instance.new("Decal")
194
Decal12 = Instance.new("Decal")
195
Decal13 = Instance.new("Decal")
196
Decal14 = Instance.new("Decal")
197
Decal15 = Instance.new("Decal")
198
Part16 = Instance.new("Part")
199
Decal17 = Instance.new("Decal")
200
Decal18 = Instance.new("Decal")
201
Decal19 = Instance.new("Decal")
202
Decal20 = Instance.new("Decal")
203
Decal21 = Instance.new("Decal")
204
Decal22 = Instance.new("Decal")
205
Model0.Name = "Piston"
206
Model0.Parent = mas
207
Part1.Name = "Bottom"
208
Part1.Parent = Model0
209
Part1.CFrame = CFrame.new(76.5, 1, 12.5, 1, 0, 0, 0, 1, 0, 0, 0, 1)
210
Part1.Position = VT(round(mouse.Hit.p.X),round(mouse.Hit.p.Y + 1),round(mouse.Hit.p.Z))
211
Part1.Size = Vector3.new(3, 2, 3)
212
Part1.BottomSurface = Enum.SurfaceType.Smooth
213
Part1.TopSurface = Enum.SurfaceType.Smooth
214
Decal2.Name = "Piston - Side - Bottom"
215
Decal2.Parent = Part1
216
Decal2.Texture = "http://www.roblox.com/asset/?id=3434723508"
217-
Decal2.Texture = "http://www.roblox.com/asset/?id=55276778"
217+
218
Decal3.Name = "Piston - Side - Bottom"
219
Decal3.Parent = Part1
220
Decal3.Texture = "http://www.roblox.com/asset/?id=3434723508"
221-
Decal3.Texture = "http://www.roblox.com/asset/?id=55276778"
221+
222
Decal4.Name = "Piston - Side - Bottom"
223
Decal4.Parent = Part1
224
Decal4.Texture = "http://www.roblox.com/asset/?id=3434723508"
225-
Decal4.Texture = "http://www.roblox.com/asset/?id=55276778"
225+
226
Decal5.Name = "Piston - Side - Bottom"
227
Decal5.Parent = Part1
228
Decal5.Texture = "http://www.roblox.com/asset/?id=3434723508"
229-
Decal5.Texture = "http://www.roblox.com/asset/?id=55276778"
229+
230
Decal6.Parent = Part1
231
Decal6.Texture = "http://www.roblox.com/asset/?id=3434723508"
232-
Decal6.Texture = "http://www.roblox.com/asset/?id=55276778"
232+
233
Decal7.Name = "Piston - Side - Bottom"
234
Decal7.Parent = Part1
235
Decal7.Texture = "http://www.roblox.com/asset/?id=3434723508"
236-
Decal7.Texture = "http://www.roblox.com/asset/?id=55276778"
236+
237
Decal8.Name = "Piston - Inner"
238
Decal8.Parent = Part1
239
Decal8.Texture = "http://www.roblox.com/asset/?id=3434723508"
240-
Decal8.Texture = "http://www.roblox.com/asset/?id=55276778"
240+
241
Weld9.Name = "BTWeld"
242
Weld9.Parent = Part1
243
Weld9.C1 = CFrame.new(0, -1.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
244
Weld9.Part0 = Part1
245
Weld9.Part1 = Part16
246
Weld9.part1 = Part16
247
Part10.Name = "Between"
248
Part10.Parent = Model0
249
Part10.CFrame = CFrame.new(76.5, 2.4375, 12.5, 1, 0, 0, 0, 1, 0, 0, 0, 1)
250
Part10.Position = Part16.Position + Vector3.new(0, -0.125, 0)
251
Part10.Color = Color3.new(0.627451, 0.372549, 0.207843)
252
Part10.Size = Vector3.new(1, 0.875, 1)
253
Part10.BottomSurface = Enum.SurfaceType.Smooth
254
Part10.BrickColor = BrickColor.new("Dark orange")
255
Part10.TopSurface = Enum.SurfaceType.Smooth
256
Part10.brickColor = BrickColor.new("Dark orange")
257
Decal11.Name = "Piston - Side - Top (Fixed)"
258
Decal11.Parent = Part10
259
Decal11.Texture = "http://www.roblox.com/asset/?id=3434723508"
260-
Decal11.Texture = "http://www.roblox.com/asset/?id=55276778"
260+
261
Decal12.Name = "Piston - Side - Top (Fixed)"
262
Decal12.Parent = Part10
263
Decal12.Texture = "http://www.roblox.com/asset/?id=3434723508"
264-
Decal12.Texture = "http://www.roblox.com/asset/?id=55276778"
264+
265
Decal13.Parent = Part10
266
Decal13.Texture = "http://www.roblox.com/asset/?id=3434723508"
267-
Decal13.Texture = "http://www.roblox.com/asset/?id=55276778"
267+
268
Decal14.Name = "Piston - Side - Top (Fixed)"
269
Decal14.Parent = Part10
270
Decal14.Texture = "http://www.roblox.com/asset/?id=3434723508"
271-
Decal14.Texture = "http://www.roblox.com/asset/?id=55276778"
271+
272
Decal15.Name = "Piston - Top (Normal)"
273
Decal15.Parent = Part10
274
Decal15.Texture = "http://www.roblox.com/asset/?id=3434723508"
275-
Decal15.Texture = "http://www.roblox.com/asset/?id=55276778"
275+
276
Part16.Name = "Top"
277
Part16.Parent = Model0
278
Part16.CFrame = CFrame.new(76.5, 2.5, 12.5, 1, 0, 0, 0, 1, 0, 0, 0, 1)
279
Part16.Position = Part1.Position + Vector3.new(0, 1.5, 0)
280
Part16.Color = Color3.new(0.627451, 0.372549, 0.207843)
281
Part16.Size = Vector3.new(3, 1, 3)
282
Part16.BottomSurface = Enum.SurfaceType.Smooth
283
Part16.BrickColor = BrickColor.new("Dark orange")
284
Part16.TopSurface = Enum.SurfaceType.Smooth
285
Part16.brickColor = BrickColor.new("Dark orange")
286
Decal17.Name = "Piston - Side - Top (Fixed)"
287
Decal17.Parent = Part16
288
Decal17.Texture = "http://www.roblox.com/asset/?id=3434723508"
289-
Decal17.Texture = "http://www.roblox.com/asset/?id=55276778"
289+
290
Decal18.Name = "Piston - Side - Top (Fixed)"
291
Decal18.Parent = Part16
292
Decal18.Texture = "http://www.roblox.com/asset/?id=3434723508"
293-
Decal18.Texture = "http://www.roblox.com/asset/?id=55276778"
293+
294
Decal19.Parent = Part16
295
Decal19.Texture = "http://www.roblox.com/asset/?id=3434723508"
296-
Decal19.Texture = "http://www.roblox.com/asset/?id=55276778"
296+
297
Decal20.Name = "Piston - Side - Top (Fixed)"
298
Decal20.Parent = Part16
299
Decal20.Texture = "http://www.roblox.com/asset/?id=3434723508"
300-
Decal20.Texture = "http://www.roblox.com/asset/?id=55276778"
300+
301
Decal21.Name = "Piston - Top (Normal)"
302
Decal21.Parent = Part16
303
Decal21.Texture = "http://www.roblox.com/asset/?id=3434723508"
304-
Decal21.Texture = "http://www.roblox.com/asset/?id=55276778"
304+
305
Decal22.Name = "Piston - Top (Normal)"
306
Decal22.Parent = Part16
307
Decal22.Texture = "http://www.roblox.com/asset/?id=3434723508"
308-
Decal22.Texture = "http://www.roblox.com/asset/?id=55276778"
308+
309
for i,v in pairs(mas:GetChildren()) do
310
	v.Parent = workspace
311
	pcall(function() v:MakeJoints() end)
312
end
313
for i,v in pairs(Model0:GetChildren()) do
314
	v:BreakJoints()
315
	v.Anchored = true
316
end
317
mas:Destroy()
318
for i,v in pairs(cors) do
319
	spawn(function()
320
		pcall(v)
321
	end)
322
end
323
end
324
end
325
326
lever = false
327
placedl = false
328
current = nil
329
330
function placelever()
331
	if disabled == false then
332
	placedl = true
333
	Model0 = Instance.new("Model",workspace)
334
	Model0.Name = "Lever"
335
	Bottom = Instance.new("Part",Model0)
336
	Bottom.Position = VT(round(mouse.Hit.p.X),round(mouse.Hit.p.Y + 0),round(mouse.Hit.p.Z))
337
	Bottom.Size = Vector3.new(4, 1, 2)
338
	Bottom.Anchored = true
339
	Lever = Instance.new("Part",Model0)
340
	Lever.BrickColor = BrickColor.new("Brown")
341
	Lever.Anchored = true
342
	Lever.Orientation = Vector3.new(0, 0, 2.5)
343
	Lever.Position = Bottom.Position + Vector3.new(0, 1.5, 0)
344
	Lever.Size = Vector3.new(0.5, 2, 0.5)
345
	Lever.Orientation = Vector3.new(0, 0, -25)
346
	Detector = Instance.new("ClickDetector",Lever)
347
	Detector.MaxActivationDistance = 32
348
	ValueT = Instance.new("NumberValue",Lever)
349
	ValueT.Value = 0
350
	function OnClick(player)
351
		if ValueT.Value == 0 then
352
			Lever.Orientation = Vector3.new(0, 0, 25)
353
			ValueT.Value = 1
354
			current.Top.Position = current.Top.Position + Vector3.new(0, 1, 0)
355
		else
356
			Lever.Orientation = Vector3.new(0, 0, -25)
357
			ValueT.Value = 0
358
			current.Top.Position = current.Top.Position - Vector3.new(0, 1, 0)
359
		end
360
	end
361
	
362
	Detector.MouseClick:connect(function()
363
		OnClick()
364
	end)
365
366
end
367
end
368
369
selecc = Instance.new("Part",char)
370
selecc.CanCollide = false
371
selecc.Anchored = true
372
selecc.BrickColor = BrickColor.new("White")
373
selecc.Transparency = 0.75
374
selecc.Material = "SmoothPlastic"
375
selecc.Size = Vector3.new(3, 3, 3)
376
377
mouse.Button1Down:connect(function()
378
	placepiston()
379
end)
380
381
mouse.KeyDown:connect(function(key)
382
	key=key:lower()
383
	if key == "e" then
384
		if disabled then
385
			disabled = false
386
			selecc.Transparency = 0.75
387
		else
388
			disabled = true
389
			selecc.Transparency = 1
390
		end
391
	end
392
	if key == "l" then
393
		placelever()
394
	end
395
	if key == "r" then
396
		if mouse.Target then
397
			if mouse.Target.Parent.Name == "Piston" then
398
				mouse.Target.Parent:Destroy()
399
			end
400
			if mouse.Target.Parent.Name == "Lever" then
401
				mouse.Target.Parent:Destroy()
402
			end
403
		end
404
	end
405
	if key == "p" then
406
		if mouse.Target then
407
			if mouse.Target.Parent.Name == "Piston" then
408
				current = mouse.Target.Parent
409
			end
410
		end
411
	end
412
end)
413
414
while true do
415
	wait()
416
	selecc.Position = VT(round(mouse.Hit.p.X),round(mouse.Hit.p.Y + 1),round(mouse.Hit.p.Z))
417
end