|
| 30 Mar 2014 11:51 AM |
I mean this should be really simple but I thought this would work..
function onTouch() Part:Destroy() end
Okay so, what did I do wrong? |
|
|
| Report Abuse |
|
|
spearman2
|
  |
| Joined: 28 May 2010 |
| Total Posts: 2938 |
|
|
| 30 Mar 2014 11:54 AM |
Part = script.Parent
function onTouch() Part:Destroy() end
Part.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2014 11:54 AM |
script.Parent.Touched:connect(function(hit) script.Parent:Destroy() end)
This script will destroy the Part when anything touches it. |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2014 11:55 AM |
But if you want it to be destroyed when a player touches it;
script.Parent.Touched:connect(function(hit) if hit.Parent:findFirstChild("Humanoid") then script.Parent:Destroy() end end) |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2014 11:59 AM |
Thanks to the both of you! Still trying to learn Lua :P
-thread closed- |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2014 12:23 PM |
Woops before I #endthread
script.Parent.Touched:connect(function(hit) if hit.Parent:findFirstChild("Humanoid") then wait(2) script.Parent:Destroy() end end)
As you can see in the script I added a wait(2) there so it doesn't destroy straight away but how do I add another if statement? I want a variable called game and if game = true then it will get rid of the part but if it's not then it won't?
|
|
|
| Report Abuse |
|
|
|
| 30 Mar 2014 12:34 PM |
OMG I actually did a script by myself XD
game = false
script.Parent.Touched:connect(function(hit) if game == false then if hit.Parent:findFirstChild("Humanoid") then wait(2) script.Parent:Destroy() end end end)
check me out lol |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2014 12:35 PM |
| I mean like I had no idea how to add conditions, I just was inserting random stuff and following the errors and it worked :D |
|
|
| Report Abuse |
|
|