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

How do i make tower counter like when you beat a tower you will get a point?

Asked by 3 years ago

but idk how that doens't need a badge im new at studio btw here is my script i guess.

local ReplicatedStorage = game:GetService('ReplicatedStorage') local BadgeService = game:GetService('BadgeService')

local function UpdateStats(Player) local Leaderstats = Player:WaitForChild('leaderstats') local Towers = Leaderstats and Leaderstats:WaitForChild('Towers')

if Leaderstats and Towers then
    local Badges = require(ReplicatedStorage.GLOBALENUMS.BadgeList)
    local Counter = 0

    for BadgeName, BadgeId in next, Badges do
        if BadgeService:UserHasBadgeAsync(Player.UserId, BadgeId) then
            Counter += 1
        end
    end

    Towers.Value = Counter
end

end

game.Players.PlayerAdded:Connect(function(Player) local Leaderstats = script.leaderstats:Clone()

Leaderstats.Parent = Player
Leaderstats.Name = 'leaderstats'

UpdateStats(Player)

end)

ReplicatedStorage.REMOTE.UpdateStats.Event:Connect(UpdateStats)

Answer this question