Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print('Running and used')
- -- Services
- local uis = game:GetService("UserInputService")
- -- Variables
- local user
- local press --> for input connection towards the user
- local release --> for input connection towards the user
- -- Tables
- local keys = {Enum.KeyCode.W, Enum.KeyCode.S, Enum.KeyCode.A, Enum.KeyCode.D}
- -- Parts and RemoteEvents
- local tool = script.Parent
- local seat = script.Parent:WaitForChild("v_seat").Value
- local function equipped(UserMouse)
- -- Start of User's Input
- press = uis.InputBegan:Connect(function (push)
- if push.KeyCode == Enum.KeyCode.W then
- print('Forward ▲')
- seat.front:FireServer(UserMouse)
- elseif push.KeyCode == Enum.KeyCode.S then
- print('Backward ▼')
- seat.back:FireServer(UserMouse)
- elseif push.KeyCode == Enum.KeyCode.A then
- print('Turning Left <<')
- seat.left:FireServer(UserMouse)
- elseif push.KeyCode == Enum.KeyCode.D then
- print('Turning Right >>')
- seat.right:FireServer(UserMouse)
- end
- end) -- End of User's Input
- -- Stopping User's Input
- release = uis.InputEnded:Connect(function (pull)
- for _, v in pairs(keys) do
- if pull.KeyCode == v then
- end
- end
- end) -- End of Stopping the input
- end
- local function unequipped(UserMouse)
- seat.stop:FireServer()
- press:Disconnect()
- release:Disconnect()
- seat.stop:FireServer()
- end
- tool.Equipped:Connect(equipped)
- tool.Unequipped:Connect(unequipped)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement