OnServerInvoke Not Running

Hello So I’m running into this issue, this code doesn’t run at all:

local Event = game.ReplicatedStorage.RemoteFunctionName
local function asked(player)
print(player.Name .. "Send The Remote")
end

Event.OnServerEvent = asked

I also tried

local Event = game.ReplicatedStorage.RemoteFunctionName
local function asked(player)
print(player.Name .. "Send The Remote")
end

Event.OnServerEvent = asked()

OnServerEvent is specifically for RemoteEvents. To recieve RemoteFunctions calls on the server, you should instead use OnServerInvoke event.

RemoteFunction.OnServerInvoke = function()

end
1 Like

Yes, I know hence the name “RemoteFunctionName”

Check your Output for any messages, we can’t really get much info from what your issue is apart from assuming a couple of things:

  • Output specifically relevant to your 2 lines of Codes (Server & Client)

  • If the Scripts you’re using aren’t Disabled/are properly working

  • If you properly defined & put the RemoteFunction in the correct spot

The first one should work though:

local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("RemoteFunctionName")

local function asked(player)
    print(player.Name .. "Send The Remote")
end

Event.OnServerEvent = asked

Try to do this instead

local Event = game.ReplicatedStorage.RemoteFunctionName
local function asked(player)
print(player.Name .. "Send The Remote")
end

Event.OnServerEvent:Connect(asked)

I had no errors client and server, no warnings or anything else it just didn’t work at all, I have also fixed the issue thank you.