Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How Do I Get This To Respawn Blocks Correctly?

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

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

2 comments

0

i could be rong though

0

I ended up removing it later due to the fact it literally did nothing and blocks continued to spawn with the same CFrame

This discussion is preserved as it was. New answers, comments, and votes are closed.