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

How to make this kill players if it's visible?

Asked by 10 years ago

What I'm asking is how do you make it so if the transperancy is 0, it kills you, but if it's transperancy is 1, it doesn't do anything to you? It'll go from invisible to visible in 10 seconds. Here is the script I am using.

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

2 answers

Log in to vote
1
Answered by
F_lipe 135
10 years ago
function onTouched (part)
              local h = script.Parent.Parent:findFirstChild ("Humanoid")
              if script.Parent.Transparency == 0 then
              h:BreakJoints()
              end
end
script.Parent.Touched:connect(onTouched)


Hope this helps you!

Ad
Log in to vote
0
Answered by
Necrorave 560 Moderation Voter
10 years ago

part.Transparency is the property your would manipulate within a script. You would be using a conditional statement checking to see the transparency. You would be using part because that the parameter you used to name the object it touches in highlighted line...

----------------------------------------
function onTouched (part)
------------------------------------------

It would look something like this:

if part.Transparency == 0 then
--Code for kill here
end

I don't want to give you everything because I feel this is a good test for you to figure out :)

I wish you luck in learning Lua!

Answer this question