Lava does not destroy spawnpoint when touched

https://gyazo.com/7d5b99979eb3e8cbd78e52ddf5409ec6

Hello, I am trying to make it where when a lava touches a spawnpoint, I am trying to make it where that spawnpoint gets destroyed

But my script does not work for some reason, I do not get errors or anything

sometimes to trigger the script, I need to die by the lava so that the spawnpoint gets destroyed

1 Like
workspace.Part:GetTouchingParts(function(part)
	if part:IsA("SpawnLocation") then
		print(part.name)
		part:Destroy()
	end
end)

local parts = workspace.Part:GetTouchingParts()
for i, v in ipairs(parts) do
	if v:IsA("SpawnLocation") then
		v:Destroy()
	end
end

rewrote the code cuz there we some mistakes

I’ll test it out (15 characters)

1 Like

:GetTouchingParts() returns a table of all baseparts touching which part you selected.

it does not work should I add a while loop in this code?

It basically does the same bug that I am trying to encounter

i switched from pairs to ipairs, try it now

Great it wokrs now!

all I did is this

while true do
	task.wait(2)
	local parts = workspace.Part:GetTouchingParts()
	for i, v in ipairs(parts) do
		if v:IsA("SpawnLocation") then
			print(parts.name)
			v:Destroy()
		end
	end
end

reason why I added a while loop is because I want the lava to destroy the spawnpoints from all 4 teams

But thanks for helping out!

1 Like

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