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

RemoteFunction sending values wrong way round?

I have a solution to this problem, but I am wondering why it does it, here's the code:

Local:

SavePositionEvent:FireServer(SelectionBox.Adornee.Position, Player)

ServerSide:

SavePositionEvent.OnServerEvent:connect(function(Player, Position)
	print("X: " ..Position.X.. "Y: " ..Position.Y.. "Z: " ..Position.Z.. "Player: " ..Player.Name)
end)

As you see when I fire it I put Position first then the Player, but when I receive it I have to put the values the other way around otherwise I get this error:

07:45:54.493 - X is not a valid member of Player 07:45:54.495 - Script 'ServerScriptService.Startup', Line 27 07:45:54.496 - Stack End

Otherwise with the two values switched around it works, just wondering why they're messed up?

1 comment

1

Local scripts send the Player no matter what. You putting Player second on the local script doesn't matter, because the local script always sends the local player as its first argument. Just a theory.

1 answer

✓ Accepted answer

Local scripts send the Player no matter what. You putting Player second on the local script doesn't matter, because the local script always sends the local player as its first argument.

This mean that when firing an event from the client, or a LocalScript, the FireServer() will send the LocalPlayer regardless of whether you put the argument into the parameters. That means that the Server Sided Script that has the event that's being called always has the Player First. Meaning you local script doesn't need the Player variable in it's parameters,

SavePositionEvent:FireServer(SelectionBox.Adornee.Position)

Hope I helped. Good Luck!

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