Invalid argument #3 (instance expected, got string)


I am making a party system for my game and I am saving the player’s party name, game mode, and difficulty that they choose to play. While saving the host’s and server’s name I got this error. (Both of these values are object values.)

The code that has the problem:

		player.ServerCreator.Host.Value = player.Name

The error:

Please help, I really don’t know what I have mistaken.

Are you storing the player.Name in a StringValue or an ObjectValue? Check the ClassName of that Value.

1 Like

My mistake, I said that they are string values, but they are actually object values.

Host is an ObjectValue not a StringValue, therefore it only accepts object values not strings. I assume you wanted to set the value to player?

player.ServerCreator.Host.Value = player
1 Like

Yea I want that value to have the player’s name

player.ServerCreator.Host.Name = player.Name

PS: If you want Host.Value to have the player’s name instead of the player instance you will have to use string values.

1 Like

I used string values but I got the same type of errors but it expected something else, brb I am gonna change it and I will send a screenshot.

The error:

Screenshot 2022-02-01 150454

The problematic line:

	ServerValue.Value = pServer

Where pServer comes from:

	local pServer = Server:GetAsync(plr.UserId)or nil

I used nil since I don’t want it to error and I want that value to be empty if the player has never joined.

ServerValue.Value = pServer or "" --if pServer is nil, make the string empty
1 Like

Alright, I guess that solved it, thanks a bunch. I will have to look more into my code because some stuff doesn’t show up for some reason. By any chance, do you know a good tutorial on how to transfer data between places (or even games if possible)? Thanks again for the help!

Oh yea I found my problem I think. I am using textboxes for players to fill the name and stuff. For some reason, the writing in that text does not transfer to the value? And no errors show up.

Places under the same universe share the same datastores. To access data between games or places that aren’t under the same universe you have to use external datastores using HttpService(and access them on both places/games using the same access keys).

1 Like

That’s really convenient :grinning: ! Thanks again!