local DF = game.Players:findFirstChild("leaderstats"):findFirstChild("stat") local BS = game:GetService("BadgeService") local list = script.Parent:WaitForChild("SG").Badges if BS:UserHasBadge(script.Parent.Parent.userId, 202862931) then list.B1.Check.Visible = true DF.Value = DF.Value + 1 end
the DF variable doesn't work and i don't know how to fix it.
the output says "Players.Player.PlayerGui.BadgesCheck:1: attempt to index a nil value"
1) I would recommend using a regular script for this(This could be integrated with your leaderstats script)
2) I would recommend using MarketplaceService
instead of BadgeService
3)You are looking for leaderstats inside Players
local Market = Game:GetService("MarketplaceService") Game.Players.PlayerAdded:connect(function(Player) if Market:PlayerOwnsAsset(Player,202862931) then local Stat = Player:WaitForChild("leaderstats"):WaitForChild("stat") Stat.Value = Stat.Value + 1 Player.PlayerGui.????.???.Visible = 1 end end)