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

Lava script doesn't work. Help?

Asked by 10 years ago

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.

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. GoldenPhysics 474 — 10y

2 answers

Log in to vote
0
Answered by 10 years ago

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)

Ad
Log in to vote
0
Answered by 10 years ago

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.

Answer this question