SendToServer passes undocumented additional parameter

Describe the bug:

When calling SendToServer on a script, the user that’s sending the message is passed as the last parameter.

This isn’t documented behavior.

This needs to be documented, and came up when calling SendToServer("AddToInventory", template) from the client. This errors because the user is being passed into the addCount parameter for that method.

How do you cause this bug?

Add this script anywhere in the game

local ExampleScript = {}

ExampleScript.Properties = {}

function ExampleScript:ClientInit()
	self:SendToServer("Test")
end

function ExampleScript:Test(entity)
	print(entity:GetName())
end

return ExampleScript

Preview the game. You’ll see the user entity is printed to the console.

This is useful behavior, but should be documented.

Which platform: PC / Stadia

Your Crayta username: Cereal

Game seen in (including “Hub” or “Editor for XYZ”): Editor

Time + date seen: Jan 8 2022

Version number (found in Help tab in Settings): 0.e3.63.114111

1 Like