Finding a Player through an ObjectValue

So im trying to make a variable for the player but when i try to run the code it says
" Argument 1 missing or nil"

this is the line that is causing the error

local Player = game:GetService("Players"):FindFirstChild(script.Parent.Parent.Player.Value)

Is the object value the player? If so then

local Player = script.Parent.Parent.Player.Value

Would already be the player, you wouldn’t need to find it again.
If It’s not the player then you should use a string, not an object.

1 Like

yes the object is the player but it still dosent work

local Players = game:GetService("Players")

local playerName = script.Parent.Parent.Player.Value
print(playerName) --If nil, make sure the value actually exists.
local player = Players:FindFirstChild(playerName)

That will be the instance player, not the name. So you could do tostring(script.Parent.Parent.Player.Value) or script.Parent.Parent.Player.Value.Name

Check if the objectvalue is in fact the player then, because it should be working.
You can test that by printing the objectvalue.Name and see if it prints the playername.

nope. same error and basically the same thing just spaced out and with other variables

Try printing it with the updated code I put.

i have tried that and it said “attempt to index nil with Name”

That means the objectvalue is nil and you didn’t set it up as the player correctly.

@Fusionet Your code works the same way OverFearful’s code works. FindFirstChild() requires a string, using an object would not work, please see Instance:FindFirstChild().

just tried and it just returns nil ;/

1 Like

the objectvalue isnt nil tho, in properties it clearly shows Overfearful

well… can we see how you applied the value to the ObjectValue?
im guessing along the lines of

Player -- should be the player instance
ObjectValue.Value = Player

yes it is written just like that

1 Like

Make sure your objectvalue location is correct!

Did you change the objectvalue through a localscript? If so then trying to find it through a serverscript wouldn’t work, since it doesn’t see what the client does.

nope both are serverside and the location is correct.

What’s supposed to be the value of the ObjectValue? What are you trying to do?

if thats the case there is no reason to use the Player service again to get the player because the objectValue is already the Player Instance(Not the name)

Finding a Player through an ObjectValue, title

I’m pretty sure the error here is how you’re defining the player object then, may you should us how you’re doing that? (script)

1 Like