Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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

0
"Player" already refers to PlayerStats. Ziffixture 6913 — 4y

1 answer

Log in to vote
1
Answered by
8oe 115 Donator
4 years ago
Edited 4 years ago

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.

Ad

Answer this question