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

hi i need help with a beginner lava block script?

hi all i can script is doors that change color coz i started 2 days ago and i need help with a lava block script

local Lava = script.Parent

function dieontouch(Brick)

local somerandomperson =

Brick.Parent:findFirstChild("Humanoid")

if (somerandomperson = ~= nil) then

somerandomperson.Health - 100

end

end

Lava.Touched:Connect(dieontouch)

2 comments

0

The Health property can't be changed by performing subtraction like that. An equal sign is required, just like how you would assign a variable to a value.

0

for 'somerandomperson = ~= nil' im pretty sure all you need is 'somerandomperson ~= nil' or else you will get an error

2 answers

Hello, so what you need to do is this: local Lava = script.Parent function dieontouch(Brick) local somerandomperson=Brick.Parent if (somerandomperson = ~= nil) then somerandomperson:BreakJoints() end end Lava.Touched:Connect(dieontouch)

Thats it.

Put this inside of a Part

script.Parent.Touched:Connect(function(WhatTouched)

    if WhatTouched.Parent:FindFirstChild("Humanoid") then

	    local hum = WhatTouched.Parent:FindFirstChild("Humanoid")

	    hum:TakeDamage(.5) --.5 amount of damage

    else

	    return

    end

end)

WhatTouched

Is the part that makes contact

WhatTouched.Parent:FindFirstChild("Humanoid")

Checks to see if there is a

Humanoid

inside of the Parent of the Part that touched and

:TakeDamage()

Only compatible with Humanoids, Takes Damage, by a given integer within the parenthesis

1 comment

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