(NOT REQUESTING A SCRIPT BTW) so i want to add a handbrake key input to my car, but since uis does not work on server scripts anymore, what should i use instead? i cant change the script to a local one, it wont work. what should i do? should i use another service? how do i fix it? thanks
How do i do key inputs to a car when UserInputService doesnt work?
1 answer
Just use them on LocalScripts. They have never "worked" on Server Scripts. They were never made on them, only LocalScripts. You're gonna have to use UserInputService, Mouse.KeyDown shouldn't be used for new work. It's bad and unefficent. Use UserInputService, and if you're making the handbrake for your car, learn RemoteEvents. Not sure what you're asking but this is all the help I can give. So a quick overview, use UserInputService and learn FE stuff. Like RemoteEvents and RemoteFunctions, Remote Events are the MOST useful.
Also quick tip when you're using UserInputService, sometimes people forget to use gameProcessed in their UserInputService and when they do, keys can execute in Chat. Chat is a gameProcessed thing so we can fix that by doing:
--LocalScript
local UserInput = game:GetService("UserInputService")
UserInput.InputBegan:Connect(function(KeyDown, gameProcessed)
--This stops it from executing in chat, make sure you have the "GameProcessed" argument near the keydown argument.
if not gameProcessed then
if KeyDown.KeyCode == Enum.KeyCode.YourKeyYouWant then
--Do something, or fire a remote event. (Learn Remotes)
end
end
end
That will be for when the user taps the key, if you want them to hold it then let go then you'd add something with the UserInput called InputEnded
I will provide the resources for these things to research up on :)
5 comments
where do i put the script, and how can i only call the input when the player is in the vehicle, not outside?
I had these same problems, but my way Is probably not the best I parented the player to the seat and put the script in starter player scripts. Then the script would check if script.Parent.Parent.Character.parent.Name == ("VehicalSeat")
by parented I mean the character was set as a child of the seat Seat.OBenjOne not OBenjOne.Seat
I'd advise you to learn lots of Lua IEatAndDisBaconHair, that's my only advice man.
Thanks but, im a pro in lua, and i searched every single wiki page and every single video on youtube, so ill try doing something else. thank you sir
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
if you want to know the player's input you gotta use Local Scripts ¯_(?)_/¯