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

Lava script doesn't work. Help?

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

0

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.

2 answers

Here is a lava script for when a person steps on it, the person dies (IF THIS IS WHAT YOU WANT)

function onTouch(part) local humanoid = part.Parent:FindFirstChild("Humanoid") if (humanoid ~= nil) then -- if a humanoid exists, then humanoid.Health = 0 -- damage the humanoid end end

script.Parent.Touched:connect(onTouch)

It's very simple. I did it like this: (There's a brick with a script inside)

script.Parent.Touched:connect(function(touched)
	local found = touched.Parent:FindFirstChild("Humanoid")
	if found then
	touched.Parent.Humanoid.Health = 0
	end
end)

Hope this helps.

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