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

How to increase Stats if user owns a badge?

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

✓ Accepted answer
  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)

1 comment

0

Thanks :D

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