For _,v loop dupping on spam

(EYES HURT WARNING)

for _,Frame in playergui.SwordInventory.Grid:GetChildren() do

    if Frame:IsA("Frame") then

        debris:AddItem(Frame,0)

    end

end

for _,event in connectedEvents do

    event:Disconnect()
    
end

local profile = remotes.GetDataStore:InvokeServer(player)

if not profile then return end

local swords = profile.Swords

local newTable = swords

table.sort(newTable, function(a, b)

    if a.Equipped == b.Equipped then

        return gameData.Swords[a.Name].Power > gameData.Swords[b.Name].Power

    end

    return a.Equipped and not b.Equipped

end)

if #newTable > 0 then

    for _,Sword in newTable do
        
        local Frame = template:Clone()

Make sure that the UI actually has time to get done with displaying everything through some sort of debounce, aka checking if it’s done and if it isn’t then drop the function
Example:

local db = false
function()
if db then return end -- checks if db is true, continues as normal if it isn't
db = true
...
db = false
end
1 Like

ty! i don’t really thinked about adding cooldowns, thanks for solution have a good day :slight_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.