Advertisement
InTesting

Chair test

Feb 24th, 2019
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.47 KB | None | 0 0
  1. if game.PlaceId == 843468296 or game.PlaceId == 843495510 or game.PlaceId == 897312463 then
  2. -- Instructions:
  3. --[[
  4. Any local variables with :
  5.  = LocalPlayer:
  6.     Must be replaced with "owner". So if your local variable is game.Players.LocalPlayer , replace it with owner
  7.  = :GetMouse():
  8.     Remove the variable entirely.
  9.  
  10. then paste this over the desired script
  11. --]]
  12.  
  13. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  14. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  15. do
  16.     print("FE Compatibility code by Mokiros | Translated to FE by iPxter")
  17.     script.Parent = Player.Character
  18.  
  19.     --RemoteEvent for communicating
  20.     local Event = Instance.new("RemoteEvent")
  21.     Event.Name = "UserInput_Event"
  22.     --Fake event to make stuff like Mouse.KeyDown work
  23.     local function fakeEvent()
  24.         local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  25.         t.connect = t.Connect
  26.         return t
  27.     end
  28.     --Creating fake input objects with fake variables
  29.     local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  30.     local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  31.     local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  32.         CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  33.     end}
  34.     --Merged 2 functions into one by checking amount of arguments
  35.     CAS.UnbindAction = CAS.BindAction
  36.  
  37.     --This function will trigger the events that have been :Connect()'ed
  38.     local function te(self,ev,...)
  39.         local t = m[ev]
  40.         if t and t._fakeEvent and t.Function then
  41.             t.Function(...)
  42.         end
  43.     end
  44.     m.TrigEvent = te
  45.     UIS.TrigEvent = te
  46.     Event.OnServerEvent:Connect(function(plr,io)
  47.         if plr~=Player then return end
  48.         if io.isMouse then
  49.             m.Target = io.Target
  50.             m.Hit = io.Hit
  51.         else
  52.             local b = io.UserInputState == Enum.UserInputState.Begin
  53.             if io.UserInputType == Enum.UserInputType.MouseButton1 then
  54.                 return m:TrigEvent(b and "Button1Down" or "Button1Up")
  55.             end
  56.             for _,t in pairs(CAS.Actions) do
  57.                 for _,k in pairs(t.Keys) do
  58.                     if k==io.KeyCode then
  59.                         t.Function(t.Name,io.UserInputState,io)
  60.                     end
  61.                 end
  62.             end
  63.             m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  64.             UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  65.         end
  66.     end)
  67.     Event.Parent = NLS([==[
  68.     local Player = game:GetService("Players").LocalPlayer
  69.     local Event = script:WaitForChild("UserInput_Event")
  70.     local UIS = game:GetService("UserInputService")
  71.     local input = function(io,a)
  72.         if a then return end
  73.         --Since InputObject is a client-side instance, we create and pass table instead
  74.         Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  75.     end
  76.     UIS.InputBegan:Connect(input)
  77.     UIS.InputEnded:Connect(input)
  78.     local Mouse = Player:GetMouse()
  79.     local h,t
  80.     --Give the server mouse data 30 times every second, but only if the values changed
  81.     --If player is not moving their mouse, client won't fire events
  82.     while wait(1/30) do
  83.         if h~=Mouse.Hit or t~=Mouse.Target then
  84.             h,t=Mouse.Hit,Mouse.Target
  85.             Event:FireServer({isMouse=true,Target=t,Hit=h})
  86.         end
  87.     end]==],Player.Character)
  88.     Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  89. end
  90. -- End of FE converter
  91. local char = owner.Character
  92. if char then
  93.     function weldi(part1,part2)
  94.         local weld0 = Instance.new("WeldConstraint",part1)
  95.         weld0.Part0 = part1
  96.         weld0.Part1 = part2
  97.     end
  98.     wait(1)
  99.     local chair = Instance.new("Model",workspace)
  100.     chair.Name = "Chair"
  101.    
  102.     local CSeat = Instance.new("Seat",chair)
  103.     CSeat.Transparency = 1
  104.     CSeat.Size = Vector3.new(2, 1, 2)
  105.     chair.PrimaryPart = CSeat
  106.     CSeat.CFrame = char.Head.CFrame * CFrame.new(0,5,0)
  107.    
  108.     local Part_1 = Instance.new("Part",chair)
  109.     Part_1.CFrame = CSeat.CFrame * CFrame.new(0,0,-.5)
  110.     Part_1.Size = Vector3.new(2.5, 1, 3)
  111.  
  112.     local Part_2 = Instance.new("Part",chair)
  113.     Part_2.CFrame = CSeat.CFrame * CFrame.new(1.625, 1.755,-.25)
  114.     Part_2.Size =  Vector3.new(0.75, 0.5, 2.5)
  115.    
  116.     local Part_3 = Instance.new("Part",chair)
  117.     Part_3.CFrame = CSeat.CFrame * CFrame.new(-1.625, 1.755,-.25)
  118.     Part_3.Size =  Vector3.new(0.75, 0.5, 2.5)
  119.    
  120.     local Part_4 = Instance.new("Part",chair)
  121.     Part_4.CFrame = CSeat.CFrame * CFrame.new(0, 1.75,.75)
  122.     Part_4.Size =  Vector3.new(2.5, 2.5, 0.5)
  123.    
  124.     local MCH = chair:GetChildren()
  125.     for _,v in pairs(MCH) do
  126.         v.BrickColor = BrickColor.new("Really red")
  127.         v.Material = Enum.Material.Fabric
  128.         weldi(chair.PrimaryPart,v)
  129.     end
  130.     CSeat.Anchored = true
  131.    
  132.     local at1 = Instance.new("Attachment",CSeat)
  133.     at1.Orientation = Vector3.new(0,0,0)
  134.     local sampar = Instance.new("Part", workspace)
  135.     sampar.Position = Vector3.new(0,-10,0)
  136.     sampar.Anchored = true
  137.     local at2 = Instance.new("Attachment",sampar)
  138.     at2.Orientation = Vector3.new(0,0,90)
  139.     local ao = Instance.new("AlignOrientation",CSeat)
  140.     ao.PrimaryAxisOnly = true
  141.     ao.Attachment0 = at1
  142.     ao.Attachment1 = at2
  143.     ao.RigidityEnabled = true
  144.     ao.AlignType = Enum.AlignType.Perpendicular
  145.    
  146.     wait(5)
  147.     CSeat.Anchored = false
  148.     wait(5)
  149.     CSeat.Anchored = true
  150. end
  151. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement