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

[Solved] Attempt to index nil with leaderstats, how else can I get the leaderstats?

Asked by 4 years ago
Edited 4 years ago

Hello! So I have this script in SSS that has to get the players money and subtract it. The script doesn't find leaderstats in the player. How would I correct this?

At first, I tried to get the player through game.Players.LocalPlayer but that doesn't work since it's in a regular script. Thanks for reading :)

    self.claimPart.Touched:Connect(function(touchedPart)
        local player = game.Players:GetPlayerFromCharacter(touchedPart.Parent) 
        if player.leaderstats.Cash.Value >= self.COST then -- this line errors
        if player and self.owner == nil and self:ownsHouse(player) == false then
            self.owner = player
0
I guess the script needed :WaitForChild on line 3 after player. Nevermind :) Ashton011 30 — 4y

Answer this question