Hi. I've created a random map script which loads a random map every so often. I decided to make it so that instead of putting a script inside each lava part, to instead make a script which automatically changes them into 'lava' bricks.
However, it doesn't seem to work. How do I fix this?
The output doesn't say anything.
Workspace.ProgramHolder.Changed:connect(function()
p = Workspace.ProgramHolder
if p:GetChildren()[1] ~= nil then
c = p:GetChildren()
for i, v in next, c:GetChildren() do
if v.Name == "lava" and v:IsA("Part") then
v.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Torso", true) then
hit.Parent.Torso.CFrame = CFrame.new(73, 148.8, -181.2) -Vector3.new(math.random(-5,5),math.random(0,0),math.random(-5, 5))
end
end)
end
end
end
end)
Thank you.

1 comment
Is the part always named lava? Also, you might want to have a mass connection line that you activate for the lava bricks OUTSIDE of the connection.