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