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

How Do I Get This To Respawn Blocks Correctly?

Asked by 9 years ago

I have a script where you step on some "tnt" blocks and they get removed and recorded into DestroyedTNT (as a CFrame value for which ones were destroyed) and then they are later respawned and the values removed by the next round script. For some reason (I believe roblox updates might have messed with it because I swear it worked a few months ago) they start to respawn on each other (if you hit one, the next round you hit it again two pop out, then three, and so on).

--I added this function in because I had no idea what else to do at this point
getTnt = function(pos)
    for _, v in pairs(game.Workspace:WaitForChild("TNTS"):GetChildren()) do
        if _ % 200 == 0 then wait(0.1) end
        if v.CFrame == pos then
            return true
        end
    end

    return nil
end

_G["NewRound"] = function()
    if game.Workspace:FindFirstChild("Main") then
        for k,v in pairs(game.Workspace.Main.DestroyedTNT:GetChildren()) do
            if getTnt(v.Value) == nil then
                local tnt = Mtnt:Clone()
                tnt.Parent = game.Workspace:WaitForChild("TNTS")
                tnt.CFrame = v.Value
            end
            v:remove()
        end
        game.Workspace.Main:remove()

1 answer

Log in to vote
-2
Answered by 9 years ago

i dont think that function that u added in at the begining is neccessary

0
i could be rong though FastSnail5 8 — 9y
0
I ended up removing it later due to the fact it literally did nothing and blocks continued to spawn with the same CFrame VariadicFunction 335 — 9y
Ad

Answer this question