Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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)
0
bump giantjdd 5 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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

  Q:FireServer(onKeyPress)

Remove onKeyPress then it should work.

0
thanks giantjdd 5 — 6y
Ad

Answer this question