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

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

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

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!

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!

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