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

hi i need help with a beginner lava block script?

Asked by 5 years ago

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)

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. DeceptiveCaster 3761 — 5y
0
for 'somerandomperson = ~= nil' im pretty sure all you need is 'somerandomperson ~= nil' or else you will get an error Fad99 286 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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.

Ad
Log in to vote
0
Answered by 5 years ago

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

Answer this question