I made this userinputservice script where if i clicked a key it would do something.

so yes this is the local script

local UIS = game:GetService("UserInputService")
UIS.InputBegan:connect(function(input,GPE)
if not GPE then	
	script.Parent.RemoteEvent:FireServer(input)
end
end)

And this is the server script part that deals with the inputservice

script.RemoteEvent.OnServerEvent:Connect(function(Input)
	
if Input.KeyCode == Enum.KeyCode.Q then

The ends are at the end as i just gave you a piece of the server script, Also the local script is in the server script if you were confused Whenever i try this script i get the error "Keycode is not a valid member of Player, Player.(MyName) idk why doe can ya please help?

8 comments

0

The first argument passed into the OnServerEvent callback is the Client's Player Instance, you need accomodate: (function(_, Input)

0

can you explain in answer? would help

0

ohh i get it now thanks you can write a answer and ill upvote it

0

wait now it says a different error "attempt to index nil with keycode???

0

You're doing script.RemoteEvent.OnServerEvent:Connect(function(_, Input) correct?

0

yes

0

this is so confusing please someone help

0

The remote events first parameter on the server is the player so instead of "Input" as the first parameter on OnServerEvent it should be (player,Input), passing the input kinda sounds risky...