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

How to increase Stats if user owns a badge?

Asked by 9 years ago
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 answer

Log in to vote
0
Answered by 9 years ago

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)
0
Thanks :D brikgame191 10 — 9y
Ad

Answer this question