Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why am I getting the error PlayerStats is not a valid member of Players "Players"?

young ROBLOX dev here I don't why this inset working like 13 years old young

script.GetClick.OnServerEvent:Connect(function(plr)
	local leaderstats = plr:WaitForChild("leaderstats")
	local Player = game.Players.PlayerStats
	local Multiplier = Player.PlayerStats.Multiplier.Value
	Multiplier = 1
	leaderstats.Clicks.Value = leaderstats.Clicks.Value + Multiplier
end)	

Background Notes

  1. I have a Server Evnt
  2. I have all these local

Thats it need help ASAP

1 comment

0

"Player" already refers to PlayerStats.

1 answer

✓ Accepted answer

You already have the Player defined in the functions parameters. As well as 'game.Players.PlayerStats' does not exist.

You must get the stats off the current player meaning, plr.PlayerStats, although I assume you mean leaderstats, you would replace PlayerStats with .leaderstats.

The correct code for your issue would be

``script.GetClick.OnServerEvent:Connect(function(plr) local leaderstats = plr:WaitForChild("leaderstats")

local Multiplier = plr.PlayerStats.Multiplier.Value -- or plr.leaderstats.Multiplier.Value

leaderstats.Clicks.Value = leaderstats.Clicks.Value + Multiplier

end) ``

I made the comment next to the Local Multiplier just in case you meant leaderstats.

I hope this helps you.

This discussion is preserved as it was. New answers, comments, and votes are closed.