Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Player = game.Players.LocalPlayer
- local RunService = game:GetService("RunService")
- local UserInputService = game:GetService("UserInputService")
- local Door = game.Workspace.Door
- local DoorPart = Door.Door
- local DoorPrimaryPart = Door.PrimaryPart
- local NearDoor = false
- RunService.RenderStepped:Connect(function()
- if Player:DistanceFromCharacter(DoorPrimaryPart.Position) < 5 then
- NearDoor = true
- DoorPrimaryPart.EToOpen.Enabled = true
- else
- NearDoor = false
- DoorPrimaryPart.EToOpen.Enabled = false
- end
- end)
- UserInputService.InputBegan:Connect(function(Input)
- if Input.UserInputType == Enum.UserInputType.Keyboard then
- local Key = Input.KeyCode
- if Key == Enum.KeyCode.E and NearDoor == true then
- Door.ToggleDoor:FireServer()
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement