|
| 16 Jun 2014 08:57 PM |
So let's say if I wanted there to be no explosion if a player touches but only when a specific part touches it, would it be like this?
function onTouched(hit) if hit.Parent:FindFirstChild("Humanoid") then return if hit.Name == "Boom" then Instance.new("Explosion") --ect... end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 09:04 PM |
function onTouched(hit) if hit.Parent:FindFirstChild("Humanoid") then return elseif hit.Name == "Boom" then Instance.new("Explosion") --ect... end
script.Parent.Touched:connect(onTouched)
Use elseif I'm not sure if there's a space inbetween those two words. |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 09:07 PM |
Ok, also at the return part, should there be an end like this? :
if hit.Parent:FindFirstChild("Humanoid") then return end |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 09:09 PM |
I actually asked myself the same question when you did that,
but I believe that you don't have to.
Using the elseif statement will make it one big funciton, so then the end would go at the bottom
I used to always use
return end
so I got confused too... But I believe the end goes at the end, because otherwise the elseif is pointless. |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2014 01:12 AM |
| But just wondering, can I still just use the 'if' statement and not the elseif? |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2014 01:31 AM |
Well I think you need two ends if you don't use elseif.
But yeah, you could do that. |
|
|
| Report Abuse |
|
|
Locard
|
  |
| Joined: 13 Apr 2014 |
| Total Posts: 3516 |
|
|
| 17 Jun 2014 01:34 AM |
script.Parent.Touched:connect(function(hit) if hit.Name == "Boom" then Instance.new("Explosion) --ect... end end)
You don't need to check if there is a person there in the first place. Just make sure that whatever you 'hit' has a specific property not relating to a person. In this case, naming it "Boom" would be pretty much settle it. |
|
|
| Report Abuse |
|
|