i am trying to make this work on a key... For example C
Could anyone help me?
local Player = game.Players.LocalPlayer script.Parent.Selected:connect(function(m) m.Button1Down:connect(function() Player.Character.Scripts.Chip.RKick:FireServer() end) end)
Use UserInputService
, it Fires when any Input is received from either the Mouse or Keyboard and more. It provides an argument holding the Input information, which in this case we can place into a Conditional for C
. It would look something like this
local UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:Connect(function(InputObject) if (InputObject.UserInputType == Enum.UserInputType.Keyboard) then if (InputObject.KeyCode == Enum.KeyCode.C) then --// Code end end end)
Hope this helps, read up on UserInputService as it can be of great use. Remember to accept this answer if it helps!
Are you trying to fire server whenever you press the button C? Then I think I have the solution:
local uis = game:GetService("UserInputService") uis.InputBegan:Connect(function(Input) if Input.KeyCode == Enum.KeyCode.C then Player.Character.Scripts.Chip.RKick:FireServer() end)