I am trying to make pressing "Q" activate something in a server script and you cant use ContextActionService in a server script so i am having to use remote events, but for some reason it is not working, please help!
Local Script:
local repStorage = game:GetService("ReplicatedStorage") local Q = repStorage:WaitForChild("Q") function onKeyPress(actionName, userInputState, inputObject) if userInputState == Enum.UserInputState.Begin then Q:FireServer(onKeyPress) end end game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.Q)
Server Script:
local repStorage = game:GetService("ReplicatedStorage") local Q = repStorage:WaitForChild("Q") Q.OnServerEvent:connect(function(player) print "hi" end)
You cant send a function, you can send a variable though.
Q:FireServer(onKeyPress)
Remove onKeyPress then it should work.