How what you get the value of an ObjectValue and use it as a StringValue?

For example, I have an ObjectValue that represents my character, and in a script I want to find the player of the character using the ObjectValue.Value how would I do this?

Every time I search through the players using the ObjectValue.Value it always returns “Instance”

But if I print(ObjectValue.Value) I get the players name as it should, I just cannot use that value to search elsewhere for that player.

3 Likes

Well it’s returning the character which is of course an instance, when you printed ObjectValue.Value it might have been printing the name of the object, which is the players name in the workspace. Use the GetPlayerFromCharacter function so you’re able to get the player from the character. An example would be:

local player = game.Players:GetPlayerFromCharacter(ObjectValue.Value)

You then have your player object so can do whatever you want, ie print(player.Name).

3 Likes

I got it.

Local player = game.Players:FindFirstChild( tostring(Object.Value)

This returned a string with the objects value which allowed me to search for the player using the objects value.

1 Like

Yeah you could do it that way or my way. Either should work.

Do ObjectValue.Value.Name. Because the value is a Player instance, so doing .Name would give the player’s name.

2 Likes

If you’ve found your solution, please mark it as a solution!