Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Me remote event is not working properly! Can someone please help!?

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)

1 comment

0

bump

1 answer

✓ Accepted answer

You cant send a function, you can send a variable though.

  Q:FireServer(onKeyPress)

Remove onKeyPress then it should work.

1 comment

0

thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.