String gets converted to an instance when fire through remote event?

I’m making a character creation system, and i’ve ran into an error. I’ve dissected it a bit and found out that a string i sent from the client has been converted to an instance when passed through the server.

LocalScript’s firing line (it’s a big script and alot of it is unrelated)

CreateCharacterEvent:FireServer("HairAccessory",Hair[HairSelectNumber],PlayerHumanoidDescription,PlayerHumanoid)

Hair = a table containing ID’s for hairs
HairSelectNumber = a number used to navigate the Hair table. (it also counts for fetching the id from the table)
PlayerHumanoid = the client’s humanoid.
PlayerHumanoidDescription = the client’s humanoid description.

ServerScript’s event line (also a big script and unrelated)

CreateCharacterEvent.OnServerEvent:Connect(function(hsstring,hsid,hs,hum) 
	if typeof(hsstring) == "string" then
		warn(hsstring)
	else
		print(typeof(hsstring))
	end
end)

The things in the brackets are what were sent in the local script.

I’d just like to know why exactly it’s doing this, or what i’m doing wrong. Thank you in advance if you can help.

2 Likes

the first parametr of remote event is the player if im not wrong try this

CreateCharacterEvent.OnServerEvent:Connect(function(player,hsstring,hsid,hs,hum) 
	if typeof(hsstring) == "string" then
		warn(hsstring)
	else
		print(typeof(hsstring))
	end
end)
1 Like

You are correct, when the client calls :FireServer() through a RemoteEvent instance from a local script the player instance pertaining to the particular client whom which fired the server is automatically passed as an argument to any callback function connected to any corresponding OnServerEvent event listener through the same RemoteEvent instance listening from the server in a server script, as such an additional parameter must be declared to handle this received player object.

2 Likes