Hi. I've just started doing keybinds and already have got stuck. This keybind should only work when you're sat in VehicleSeat and click "C".
local click = game.Players.LocalPlayer:GetMouse() local bus = script.Parent.Value.Value click.KeyDown:connect(function(key) if key=="c" then bus.Body.Lights.Blinkers.RightValue.Value = true end end)
This seems to be a localscript so you should probably use userinputservice as it is very useful other than using player's mouse
you could use it like the following for your certain action.
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(InputKey, gameProcess)
if gameProcess then return end --If the player is chatting then ignore his input
if InputKey.KeyCode == Enum.KeyCode.C then --Check if the keyPressed was the Key C you can change this to any key you want
--Your actions here
end
end)
Hope this helped.
Hello!
You should use UserInputService
. Here's a simple code I've made for you.
local UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:Connect(function(Input, Box) if Input.KeyCode == Enum.KeyCode.G and not Box then print("Key G has been pressed!") end end)
Remember: Input
is an object. That's why you have to do Input.KeyCode.