enser14
|
  |
| Joined: 28 Oct 2012 |
| Total Posts: 258 |
|
|
| 19 Oct 2015 01:31 PM |
function ontouch(part) if part.name == "nail" or part.Name == "WeldPart" then remove end <==== the error end script.Parent.Touched:connect(ontouch)
says error were end is why is this? |
|
|
| Report Abuse |
|
|
Solotaire
|
  |
| Joined: 30 Jul 2009 |
| Total Posts: 30356 |
|
|
| 19 Oct 2015 01:32 PM |
| you aren't removing anything |
|
|
| Report Abuse |
|
|
enser14
|
  |
| Joined: 28 Oct 2012 |
| Total Posts: 258 |
|
|
| 19 Oct 2015 01:35 PM |
| What do you mean? am i missing somthing that is needed before the end? |
|
|
| Report Abuse |
|
|
|
| 19 Oct 2015 01:39 PM |
| instead of remove, try destroy() |
|
|
| Report Abuse |
|
|
Solotaire
|
  |
| Joined: 30 Jul 2009 |
| Total Posts: 30356 |
|
|
| 19 Oct 2015 01:40 PM |
part:Destroy() or script.Parent:Destroy()
it's not clear which one you want |
|
|
| Report Abuse |
|
|
|
| 19 Oct 2015 01:41 PM |
function ontouched(part) local d = part.Parent:GetChildren() for i=1, #d do if (d[i].Name == "nail") or (d[i].Name == "WeldPart" then d[i]:remove() end end end
script.Parent.Touched:connect(ontouched)
Your script isn't finding what is being removed. Remove is a tricky function, you have to specify what it's removing with :remove() rather than write it as then remove.
|
|
|
| Report Abuse |
|
|
enser14
|
  |
| Joined: 28 Oct 2012 |
| Total Posts: 258 |
|
| |
|
enser14
|
  |
| Joined: 28 Oct 2012 |
| Total Posts: 258 |
|
|
| 19 Oct 2015 01:51 PM |
| but does this do if part named nail or weldpart remove or just removes those parts no matter what hits brick that triggers the script. |
|
|
| Report Abuse |
|
|
|
| 19 Oct 2015 02:06 PM |
The line: local d = hit.Parent:GetChildren() makes it so that the hit is whatever part comes in contact with the part the script is inserted in, and .Parent is the model the nail/WeldPart is inserted into (say your Character).
Example:
> Player1 (model) nail weldpart head torso leg1 leg2 arm1 arm2
|
|
|
| Report Abuse |
|
|
|
| 19 Oct 2015 02:08 PM |
Basically, whatever touches the part, if it has a part or object named WeldPart/nail inserted in it, they will be deleted.
It's comparable to a hat remover. |
|
|
| Report Abuse |
|
|