Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

VIP Gamepass Point Increase Script Error?

Asked by 2 years ago

So this is what I have so far.

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        if game.MarketplaceService:PlayerOwnsAsset(player, 1609776713) then
            while true do
            player.leaderstats.Points.Value = player.leaderstats.Points.Value + 15 
            wait(60)
            print("Gave Player 15 Points")
            end
        end
    end)
end)

It gives me this error output

20:47:19.871 - leaderstats is not a valid member of Player
20:47:19.872 - Stack Begin
20:47:19.872 - Script 'Workspace.VIPIncrease', Line 5
20:47:19.873 - Stack End

I looked inside my character while playing and he definitely does have leaderstats as a child. I'm not sure what is going on.

1
Is it spelt "leaderstats" and not "Leaderstats" or "LeaderStats"? Maybe use WaitForChild on them. player:WaitForChild("leaderstats") User#19524 170 — 2y
0
It is spelled "leaderstats". Using "player:WaitForChild("leaderstats")" worked though!!! Thanks! Mathboy9809 4 — 2y
0
Put an answer to my question and I'll mark you as answered :D Mathboy9809 4 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

Use WaitForChild on the leaderstats. Seeing this runs right when the player is added and the PlayerAdded event (on another script) fires, they fired twice. So the leaderstats script was still making while the game pass script was expecting it.

Ad

Answer this question