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

This script wont work. What did I do wrong?

Asked by 10 years ago

It's where if the part is transparent, it does no damage, but if it's opaque, it kills you instantly. I don't know what I did wrong.

while true do
    wait(10)
    script.Parent.Transparency = 1
    wait(10)
    script.Parent.Transparency = 0




function onTouched (part)
    if part.Transparency == 0 then
              local h = script.Parent.Parent:findFirstChild ("Humanoid")
              h.Health = 0
              end
end
end
script.Parent.Touched:connect(onTouched)


0
Trying putting the while loop in another script. While you can get this working in one script if you tried hard enough, it would just be easier having two separate scripts... Necrorave 560 — 10y
0
Alright. Thanks. c: TheRings0fSaturn 28 — 10y
0
Still doesn't kill. TheRings0fSaturn 28 — 10y
0
Capitalization issue...FindFirstChild(). You did not capitalize the 'f' in First Necrorave 560 — 10y
0
Oh. Thanks! :) TheRings0fSaturn 28 — 10y

1 answer

Log in to vote
0
Answered by
war8989 35
10 years ago

This should work:

script.Parent.Touched:connect(function(hit)
    humanoid = hit.Parent:findFirstChild("Humanoid")
    if(humanoid ~= nil and script.Parent.Transparency == 0) then
        humanoid.Health = 0
    end
end)

What I am doing is checking if a Humanoid exists and that the part is not transparent, if so, kill the player who touched the block, if not, do nothing.

Ad

Answer this question