Advertisement
RoScripter

Keybind Door Client

Jun 19th, 2020
2,942
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. local Player = game.Players.LocalPlayer
  2. local RunService = game:GetService("RunService")
  3. local UserInputService = game:GetService("UserInputService")
  4.  
  5.  
  6. local Door = game.Workspace.Door
  7. local DoorPart = Door.Door
  8. local DoorPrimaryPart = Door.PrimaryPart
  9.  
  10. local NearDoor = false
  11.  
  12. RunService.RenderStepped:Connect(function()
  13.     if Player:DistanceFromCharacter(DoorPrimaryPart.Position) < 5 then
  14.         NearDoor = true
  15.         DoorPrimaryPart.EToOpen.Enabled = true
  16.     else
  17.         NearDoor = false
  18.         DoorPrimaryPart.EToOpen.Enabled = false
  19.     end
  20. end)
  21.  
  22. UserInputService.InputBegan:Connect(function(Input)
  23.     if Input.UserInputType ==   Enum.UserInputType.Keyboard then
  24.         local Key = Input.KeyCode
  25.         if Key == Enum.KeyCode.E and NearDoor == true then
  26.             Door.ToggleDoor:FireServer()
  27.         end
  28.     end
  29. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement