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

Why does my auto equip tool script only work sometimes?

Asked by 2 years ago

I've created a script that auto equips an item, it works most of the time but sometimes it glitches and doesn't work? Did I do something wrong?

local ServerStorage = game:GetService("ServerStorage")
local plrs = {}

repeat wait(1) until game.Players.NumPlayers >= 1

for i, player in pairs(game.Players:GetPlayers()) do
    if player then
        table.insert(plrs,player)
    end
end

wait(2)

for i, player in pairs(plrs) do
    if player then
        character = player.Character

        if character then
            local Frostgore = ServerStorage["Arm"]:Clone()
            Frostgore.Parent = player.Backpack
            wait()
            character.Humanoid:EquipTool(Frostgore)
            wait(0.5)

        else
            if not player then
                table.remove(plrs, i)
            end

        end
    end
end

Answer this question