Atempt to call instance value error

game.Players[Randomplayer].PlayerScripts.Bear.Value = true

In the output it shows…
Randomplayer is a variable which is set to a players name
Workspace.StartUp:80: attempt to call a Instance value

Please Help

LargeHotDogs13

I don’t use values for players, so I’m not sure but try this
game.Players:FindFirstChild(Randomplayer).PlayerScripts.Bear.Value = true

1 Like

That doesn’t call anything. You’ll have to provide the actual error site in order to get any help.

1 Like

Click on the error in the output window and it’ll take you to the line in the script at which the error occurred.

1 Like

This is the error that shows up.
Workspace.StartUp:80: attempt to index nil with ‘PlayerScripts’

FindFirstChild(Randomplayer)

Means this is nil.

1 Like

So the problem isn’t on that line, can you show the full script?

1 Like

Is this a Local Script or a Server Script? Because if this is a Server Script, Server Scripts cannot access PlayerScripts, since PlayerScripts is created by the client.

You should move your Bear Value to ReplicatedStorage, PlayerGui, or in StarterCharacterScripts, wherever server scripts can access the Value.

1 Like