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

Help clean this script up? some glitch makes it stop working after a few times through?

Asked by 5 years ago

For some reason my script is getting stuck here but i dont really know what needs to change

    for _, player in pairs(game.Players:GetPlayers()) do
        local stats = player.leaderstats
        local wins = stats.Wins
        local kills = stats.Kills
        local gold = stats.Gold
        local totalGold

        setTeam(player, "In Lobby")
        if player.Character.Name == winner then
            wins.Value = wins.Value + 1
            if wins.Value >= 1 then
                game:GetService("BadgeService"):AwardBadge(player.userId, 2124451684) 
            end
            if wins.Value >= 100 then
                game:GetService("BadgeService"):AwardBadge(player.userId, 2124451685) 
            end
            if wins.Value >= 1000 then
                game:GetService("BadgeService"):AwardBadge(player.userId, 2124451686) 
            end
            player.Character.Head:Destroy()
            gold.Value = gold.Value + 5
        end
        local goldGained = kills.value
        totalGold = gold.Value + goldGained
        gold.Value = totalGold
        kills.Value = 0
        player.Character.Humanoid.NameDisplayDistance = 60
        player.Character.Humanoid.HealthDisplayDistance = 60
    end
    wait(5)
    if mapNum == 1 then
        game.Workspace.Grasslands.Parent = game.ReplicatedStorage.Maps
    elseif mapNum == 2 then
        game.Workspace.SnowBanks.Parent = game.ReplicatedStorage.Maps
    elseif mapNum == 3 then
        game.Workspace.Forest.Parent = game.ReplicatedStorage.Maps
    end

It might have something to do with a player already owning a badge but i know for sure and if it is I don't know a way around it

0
I don't know for sure** hamburger621 34 — 5y

Answer this question