Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i do key inputs to a car when UserInputService doesnt work?

Asked by 5 years ago

(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

0
if you want to know the player's input you gotta use Local Scripts ¯\_(?)_/¯ SirDerpyHerp 262 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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 :)

UserInputService

UserInputService - InputBegan

UserInputService - InputEnded

Remote Events and Remote Functions

Roblox Client and Server Model System

0
where do i put the script, and how can i only call the input when the player is in the vehicle, not outside? ieatandisbaconhair 77 — 5y
0
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") OBenjOne 190 — 5y
0
by parented I mean the character was set as a child of the seat Seat.OBenjOne not OBenjOne.Seat OBenjOne 190 — 5y
0
I'd advise you to learn lots of Lua IEatAndDisBaconHair, that's my only advice man. User#21998 0 — 5y
0
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 ieatandisbaconhair 77 — 5y
Ad

Answer this question