I have been getting this error with a RemoteFunction, I am sending back a table of Player Usernames when It gets called for a ServerInvoke on my Client.
OnServerInvoke is a callback member of RemoteFunction; you can only set the callback value, get is not available
This is an example of my code:
Server:
local WinnerTable = game:GetService("ReplicatedStorage"):WaitForChild("QEvents"):WaitForChild("Winner"):WaitForChild("WinnerTable") local winners = {"Roblox"} WinnerTable.OnServerInvoke:Connect(function() return winners end)
Client:
local WinnerTable = game:GetService("ReplicatedStorage"):WaitForChild("QEvents"):WaitForChild("Winner"):WaitForChild("WinnerTable") local winners = WinnerTable:InvokeServer() for i,v in ipairs(winners) do winners = winners + 1 end
Remote functions aren't the same as remote events.
This is the place where you made the mistake
WinnerTable.OnServerInvoke:Connect(function() end)
Instead you should use this
function WinnerTable.OnServerInvoke() end)
Here's a very simple one it will Damage the player by 10 damage upon spawning:
local script
RF = game.Lighting.RemoteFunction local player = game.Players.LocalPlayer local char = player.CharacterAdded:wait() local result = RF:InvokeServer(char.Humanoid) char.Humanoid:TakeDamage(result)
ServerScript
RF = game.Lighting.RemoteFunction RF.OnServerInvoke = function(Player,Received) --First Info is always the Player print(Received) -- Shows that I've sent over a value from the client side Damage = 10 return Damage end
RF is the remotefunction's remote, that I've placed inside lighting.