Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
- local Player,game,owner = owner,game
- local RealPlayer = Player
- do
- print("FE Compatibility code V2 by Mokiros")
- local RealPlayer = RealPlayer
- script.Parent = RealPlayer.Character
- --Fake event to make stuff like Mouse.KeyDown work
- local Disconnect_Function = function(this)
- this[1].Functions[this[2]] = nil
- end
- local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
- local FakeEvent_Metatable = {__index={
- Connect = function(this,f)
- local i = tostring(math.random(0,10000))
- while this.Functions[i] do
- i = tostring(math.random(0,10000))
- end
- this.Functions[i] = f
- return setmetatable({this,i},Disconnect_Metatable)
- end
- }}
- FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
- local function fakeEvent()
- return setmetatable({Functions={}},FakeEvent_Metatable)
- end
- --Creating fake input objects with fake variables
- local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
- FakeMouse.keyUp = FakeMouse.KeyUp
- FakeMouse.keyDown = FakeMouse.KeyDown
- local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
- local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
- CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
- end}
- --Merged 2 functions into one by checking amount of arguments
- CAS.UnbindAction = CAS.BindAction
- --This function will trigger the events that have been :Connect()'ed
- local function TriggerEvent(self,ev,...)
- for _,f in pairs(self[ev].Functions) do
- f(...)
- end
- end
- FakeMouse.TriggerEvent = TriggerEvent
- UIS.TriggerEvent = TriggerEvent
- --Client communication
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput_Event"
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=RealPlayer then return end
- FakeMouse.Target = io.Target
- FakeMouse.Hit = io.Hit
- if not io.isMouse then
- local b = io.UserInputState == Enum.UserInputState.Begin
- if io.UserInputType == Enum.UserInputType.MouseButton1 then
- return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
- end
- if io.UserInputType == Enum.UserInputType.MouseButton2 then
- return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
- end
- for _,t in pairs(CAS.Actions) do
- for _,k in pairs(t.Keys) do
- if k==io.KeyCode then
- t.Function(t.Name,io.UserInputState,io)
- end
- end
- end
- FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
- UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
- end
- end)
- Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
- local Mouse = owner:GetMouse()
- local UIS = game:GetService("UserInputService")
- local input = function(io,RobloxHandled)
- if RobloxHandled then return end
- --Since InputObject is a client-side instance, we create and pass table instead
- Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
- end
- UIS.InputBegan:Connect(input)
- UIS.InputEnded:Connect(input)
- local h,t
- --Give the server mouse data every second frame, but only if the values changed
- --If player is not moving their mouse, client won't fire events
- local HB = game:GetService("RunService").Heartbeat
- while true do
- if h~=Mouse.Hit or t~=Mouse.Target then
- h,t=Mouse.Hit,Mouse.Target
- Event:FireServer({isMouse=true,Target=t,Hit=h})
- end
- --Wait 2 frames
- for i=1,2 do
- HB:Wait()
- end
- end]==],script)
- ----Sandboxed game object that allows the usage of client-side methods and services
- --Real game object
- local RealGame = game
- --Metatable for fake service
- local FakeService_Metatable = {
- __index = function(self,k)
- local s = rawget(self,"_RealService")
- if s then
- return typeof(s[k])=="function"
- and function(_,...)return s[k](s,...)end or s[k]
- end
- end,
- __newindex = function(self,k,v)
- local s = rawget(self,"_RealService")
- if s then s[k]=v end
- end
- }
- local function FakeService(t,RealService)
- t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
- return setmetatable(t,FakeService_Metatable)
- end
- --Fake game object
- local FakeGame = {
- GetService = function(self,s)
- return rawget(self,s) or RealGame:GetService(s)
- end,
- Players = FakeService({
- LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
- },"Players"),
- UserInputService = FakeService(UIS,"UserInputService"),
- ContextActionService = FakeService(CAS,"ContextActionService"),
- RunService = FakeService({
- _btrs = {},
- RenderStepped = RealGame:GetService("RunService").Heartbeat,
- BindToRenderStep = function(self,name,_,fun)
- self._btrs[name] = self.Heartbeat:Connect(fun)
- end,
- UnbindFromRenderStep = function(self,name)
- self._btrs[name]:Disconnect()
- end,
- },"RunService")
- }
- rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
- FakeGame.service = FakeGame.GetService
- FakeService(FakeGame,game)
- --Changing owner to fake player object to support owner:GetMouse()
- game,owner = FakeGame,FakeGame.Players.LocalPlayer
- end
- plr = owner
- char = plr.Character
- mouse = plr:GetMouse()
- disabled = false
- function round(n)
- return n % 1 >= 0.5 and math.ceil(n) or math.floor(n)
- end
- VT = Vector3.new
- function placepiston()
- if disabled == false then
- --Converted with ttyyuu12345's model to script plugin v4
- function sandbox(var,func)
- local env = getfenv(func)
- local newenv = setmetatable({},{
- __index = function(self,k)
- if k=="script" then
- return var
- else
- return env[k]
- end
- end,
- })
- setfenv(func,newenv)
- return func
- end
- cors = {}
- mas = Instance.new("Model",game:GetService("Lighting"))
- Model0 = Instance.new("Model")
- Part1 = Instance.new("Part")
- Decal2 = Instance.new("Decal")
- Decal3 = Instance.new("Decal")
- Decal4 = Instance.new("Decal")
- Decal5 = Instance.new("Decal")
- Decal6 = Instance.new("Decal")
- Decal7 = Instance.new("Decal")
- Decal8 = Instance.new("Decal")
- Weld9 = Instance.new("Weld")
- Part10 = Instance.new("Part")
- Decal11 = Instance.new("Decal")
- Decal12 = Instance.new("Decal")
- Decal13 = Instance.new("Decal")
- Decal14 = Instance.new("Decal")
- Decal15 = Instance.new("Decal")
- Part16 = Instance.new("Part")
- Decal17 = Instance.new("Decal")
- Decal18 = Instance.new("Decal")
- Decal19 = Instance.new("Decal")
- Decal20 = Instance.new("Decal")
- Decal21 = Instance.new("Decal")
- Decal22 = Instance.new("Decal")
- Model0.Name = "Piston"
- Model0.Parent = mas
- Part1.Name = "Bottom"
- Part1.Parent = Model0
- Part1.CFrame = CFrame.new(76.5, 1, 12.5, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- Part1.Position = VT(round(mouse.Hit.p.X),round(mouse.Hit.p.Y + 1),round(mouse.Hit.p.Z))
- Part1.Size = Vector3.new(3, 2, 3)
- Part1.BottomSurface = Enum.SurfaceType.Smooth
- Part1.TopSurface = Enum.SurfaceType.Smooth
- Decal2.Name = "Piston - Side - Bottom"
- Decal2.Parent = Part1
- Decal2.Texture = "http://www.roblox.com/asset/?id=151781273"
- Decal2.Face = Enum.NormalId.Right
- Decal3.Name = "Piston - Side - Bottom"
- Decal3.Parent = Part1
- Decal3.Texture = "http://www.roblox.com/asset/?id=151781273"
- Decal3.Face = Enum.NormalId.Left
- Decal4.Name = "Piston - Side - Bottom"
- Decal4.Parent = Part1
- Decal4.Texture = "http://www.roblox.com/asset/?id=151781273"
- Decal4.Face = Enum.NormalId.Left
- Decal5.Name = "Piston - Side - Bottom"
- Decal5.Parent = Part1
- Decal5.Texture = "http://www.roblox.com/asset/?id=151781273"
- Decal6.Name = "Piston - Side - Bottom"
- Decal6.Parent = Part1
- Decal6.Texture = "http://www.roblox.com/asset/?id=151781273"
- Decal6.Face = Enum.NormalId.Back
- Decal7.Name = "Piston - Side - Bottom"
- Decal7.Parent = Part1
- Decal7.Texture = "http://www.roblox.com/asset/?id=151781273"
- Decal7.Face = Enum.NormalId.Bottom
- Decal8.Name = "Piston - Inner"
- Decal8.Parent = Part1
- Decal8.Texture = "http://www.roblox.com/asset/?id=151781231"
- Decal8.Face = Enum.NormalId.Top
- Weld9.Name = "BTWeld"
- Weld9.Parent = Part1
- Weld9.C1 = CFrame.new(0, -1.5, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- Weld9.Part0 = Part1
- Weld9.Part1 = Part16
- Weld9.part1 = Part16
- Part10.Name = "Between"
- Part10.Parent = Model0
- Part10.CFrame = CFrame.new(76.5, 2.4375, 12.5, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- Part10.Position = Part16.Position + Vector3.new(0, -0.125, 0)
- Part10.Color = Color3.new(0.627451, 0.372549, 0.207843)
- Part10.Size = Vector3.new(1, 0.875, 1)
- Part10.BottomSurface = Enum.SurfaceType.Smooth
- Part10.BrickColor = BrickColor.new("Dark orange")
- Part10.TopSurface = Enum.SurfaceType.Smooth
- Part10.brickColor = BrickColor.new("Dark orange")
- Decal11.Name = "Piston - Side - Top (Fixed)"
- Decal11.Parent = Part10
- Decal11.Texture = "http://www.roblox.com/asset/?id=151782804"
- Decal11.Face = Enum.NormalId.Left
- Decal12.Name = "Piston - Side - Top (Fixed)"
- Decal12.Parent = Part10
- Decal12.Texture = "http://www.roblox.com/asset/?id=151782804"
- Decal13.Name = "Piston - Side - Top (Fixed)"
- Decal13.Parent = Part10
- Decal13.Texture = "http://www.roblox.com/asset/?id=151782804"
- Decal13.Face = Enum.NormalId.Right
- Decal14.Name = "Piston - Side - Top (Fixed)"
- Decal14.Parent = Part10
- Decal14.Texture = "http://www.roblox.com/asset/?id=151782804"
- Decal14.Face = Enum.NormalId.Back
- Decal15.Name = "Piston - Top (Normal)"
- Decal15.Parent = Part10
- Decal15.Texture = "http://www.roblox.com/asset/?id=151781353"
- Decal15.Face = Enum.NormalId.Top
- Part16.Name = "Top"
- Part16.Parent = Model0
- Part16.CFrame = CFrame.new(76.5, 2.5, 12.5, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- Part16.Position = Part1.Position + Vector3.new(0, 1.5, 0)
- Part16.Color = Color3.new(0.627451, 0.372549, 0.207843)
- Part16.Size = Vector3.new(3, 1, 3)
- Part16.BottomSurface = Enum.SurfaceType.Smooth
- Part16.BrickColor = BrickColor.new("Dark orange")
- Part16.TopSurface = Enum.SurfaceType.Smooth
- Part16.brickColor = BrickColor.new("Dark orange")
- Decal17.Name = "Piston - Side - Top (Fixed)"
- Decal17.Parent = Part16
- Decal17.Texture = "http://www.roblox.com/asset/?id=151782804"
- Decal17.Face = Enum.NormalId.Left
- Decal18.Name = "Piston - Side - Top (Fixed)"
- Decal18.Parent = Part16
- Decal18.Texture = "http://www.roblox.com/asset/?id=151782804"
- Decal19.Name = "Piston - Side - Top (Fixed)"
- Decal19.Parent = Part16
- Decal19.Texture = "http://www.roblox.com/asset/?id=151782804"
- Decal19.Face = Enum.NormalId.Right
- Decal20.Name = "Piston - Side - Top (Fixed)"
- Decal20.Parent = Part16
- Decal20.Texture = "http://www.roblox.com/asset/?id=151782804"
- Decal20.Face = Enum.NormalId.Back
- Decal21.Name = "Piston - Top (Normal)"
- Decal21.Parent = Part16
- Decal21.Texture = "http://www.roblox.com/asset/?id=151781353"
- Decal21.Face = Enum.NormalId.Top
- Decal22.Name = "Piston - Top (Normal)"
- Decal22.Parent = Part16
- Decal22.Texture = "http://www.roblox.com/asset/?id=151781353"
- Decal22.Face = Enum.NormalId.Bottom
- for i,v in pairs(mas:GetChildren()) do
- v.Parent = workspace
- pcall(function() v:MakeJoints() end)
- end
- for i,v in pairs(Model0:GetChildren()) do
- v:BreakJoints()
- v.Anchored = true
- end
- mas:Destroy()
- for i,v in pairs(cors) do
- spawn(function()
- pcall(v)
- end)
- end
- end
- end
- lever = false
- placedl = false
- current = nil
- function placelever()
- if disabled == false then
- placedl = true
- Model0 = Instance.new("Model",workspace)
- Model0.Name = "Lever"
- Bottom = Instance.new("Part",Model0)
- Bottom.Position = VT(round(mouse.Hit.p.X),round(mouse.Hit.p.Y + 0),round(mouse.Hit.p.Z))
- Bottom.Size = Vector3.new(4, 1, 2)
- Bottom.Anchored = true
- Lever = Instance.new("Part",Model0)
- Lever.BrickColor = BrickColor.new("Brown")
- Lever.Anchored = true
- Lever.Orientation = Vector3.new(0, 0, 2.5)
- Lever.Position = Bottom.Position + Vector3.new(0, 1.5, 0)
- Lever.Size = Vector3.new(0.5, 2, 0.5)
- Lever.Orientation = Vector3.new(0, 0, -25)
- Detector = Instance.new("ClickDetector",Lever)
- Detector.MaxActivationDistance = 32
- ValueT = Instance.new("NumberValue",Lever)
- ValueT.Value = 0
- function OnClick(player)
- if ValueT.Value == 0 then
- Lever.Orientation = Vector3.new(0, 0, 25)
- ValueT.Value = 1
- current.Top.Position = current.Top.Position + Vector3.new(0, 1, 0)
- else
- Lever.Orientation = Vector3.new(0, 0, -25)
- ValueT.Value = 0
- current.Top.Position = current.Top.Position - Vector3.new(0, 1, 0)
- end
- end
- Detector.MouseClick:connect(function()
- OnClick()
- end)
- end
- end
- selecc = Instance.new("Part",char)
- selecc.CanCollide = false
- selecc.Anchored = true
- selecc.BrickColor = BrickColor.new("White")
- selecc.Transparency = 0.75
- selecc.Material = "SmoothPlastic"
- selecc.Size = Vector3.new(3, 3, 3)
- mouse.Button1Down:connect(function()
- placepiston()
- end)
- mouse.KeyDown:connect(function(key)
- key=key:lower()
- if key == "e" then
- if disabled then
- disabled = false
- selecc.Transparency = 0.75
- else
- disabled = true
- selecc.Transparency = 1
- end
- end
- if key == "l" then
- placelever()
- end
- if key == "r" then
- if mouse.Target then
- if mouse.Target.Parent.Name == "Piston" then
- mouse.Target.Parent:Destroy()
- end
- if mouse.Target.Parent.Name == "Lever" then
- mouse.Target.Parent:Destroy()
- end
- end
- end
- if key == "p" then
- if mouse.Target then
- if mouse.Target.Parent.Name == "Piston" then
- current = mouse.Target.Parent
- end
- end
- end
- end)
- while true do
- wait()
- selecc.Position = VT(round(mouse.Hit.p.X),round(mouse.Hit.p.Y + 1),round(mouse.Hit.p.Z))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement