#auras spawning too many times

1 messages · Page 1 of 1 (latest)

torpid hound
#
local auraStolen = game.ReplicatedStorage.Events:FindFirstChild("AuraStolen")
local collectionZone = script.Parent
local base = collectionZone.Parent
local auras = base:FindFirstChild("AuraStorage")
local auraStands = game.ServerStorage.Assets:FindFirstChild("AuraStands")

local function collectAura(aura)
    if not auras then
        warn("AuraStorage not found!")
        return
    end
    if not auraStands then
        warn("AuraStands not found!")
        return
    end
    for i, stand in auras:GetChildren() do
        if stand:IsA("ValueBase") and stand.Value == "" then
            local standPart = stand.Parent:FindFirstChild("Stand") or stand:FindFirstChild("Stand")
            if standPart then
                stand.Value = aura
                local displayedAura = auraStands:FindFirstChild(aura)
                if displayedAura then
                    local auraClone = displayedAura:Clone()
                    if auraClone.PrimaryPart then
                        auraClone:SetPrimaryPartCFrame(standPart.CFrame + Vector3.new(0, 3.5, 0))
                    else
                        auraClone:MoveTo(standPart.Position + Vector3.new(0, 3.5, 0))
                    end
                    auraClone.Parent = standPart
                else
                    print("gurt")
                end
                return
            else
                warn("yo gurt")
            end
        end
    end
end

collectionZone.Touched:Connect(function(part)
    local auraModel = part:FindFirstAncestorWhichIsA("Model")
    if not auraModel then return end
    if part:FindFirstAncestor("Auras") then
        collectAura(auraModel.Name)
        auraModel:Destroy()
    elseif part:FindFirstAncestor("StolenAuras") then
        if auraStolen then
            if auraModel:FindFirstChild("Base").Value == collectionZone.Parent.Name then return end
            collectAura(auraModel.Name)
            auraStolen:Fire(auraModel)
        end
    end
end)
#

i tried to fix this problem like 15 times and even tried to get ai to fix the script and it still doesn't work (Only happens when auras are stolen) 🥀

torpid hound
turbid relic
#

💔

#

Maybe ask roblox assistant

#

Ctrl + j

torpid hound
#

roblox assistant is ass

turbid relic
half sand
#

we tried both, niether are working

turbid relic
#

Learn Luau

compact river
#

Add debounce to touched event

glad venture
#

🗣️

obsidian swift
# compact river Add debounce to touched event

yeah which looks like this btw:

local debounce = false
collectionZone.Touched:Connect(function(part)
if debounce then return end
-- ur code
debounce = true
task.wait(anycooldownyouwant)
debounce = false
end)
#

the reason you could need a debounce is that the touched event fires rapidly multiple times due to the slightest trigger so a debounce helps you control it a bit more

half sand
half sand
#

oh wait no this problem has been solved

#

my bad, can you go to the new one I made "stealing twice don't work"

torpid hound