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

error says attempt to index nil with leaderstats. Can someone help?

local Players = game:GetService("Players")

Players.PlayerAdded:connect(function(player)
	if player.MembershipType == Enum.MembershipType.Premium then
		wait(3)
	local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
		plr.leaderstats.Breaths.Value = plr.leaderstats.Breaths.Value +50
	else
		print("Player Does Not Have Premium")
	end	
end)

1 answer

✓ Accepted answer

Why did you make another variable? Just use player from the PlayerAdded event.

local Players = game:GetService("Players")

Players.PlayerAdded:connect(function(player)
    if player.MembershipType == Enum.MembershipType.Premium then
        wait(3)
        player.leaderstats.Breaths.Value = player.leaderstats.Breaths.Value + 50
    else
        print("Player Does Not Have Premium")
    end 
end)

Hope this helps

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