M16Micah
|
  |
| Joined: 04 Apr 2009 |
| Total Posts: 891 |
|
|
| 16 Jun 2010 09:04 PM |
function stringcheese(hit) if hit.Parent.Name == "your name here" then hit.Parent.Head:remove() end end script.Parent.Touched:connect(stringcheese) |
|
|
| Report Abuse |
|
|
mako123
|
  |
| Joined: 18 Dec 2008 |
| Total Posts: 1125 |
|
|
| 16 Jun 2010 09:07 PM |
function stringcheese(hit) if hit.Parent.Name == "your name here" then while true do hit.Parent.Head:remove() end end end script.Parent.Touched:connect(stringcheese)
Nice function name btw :P |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2010 09:10 PM |
@mako
You need wait() or game will crash without wait(). |
|
|
| Report Abuse |
|
|
mako123
|
  |
| Joined: 18 Dec 2008 |
| Total Posts: 1125 |
|
| |
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 16 Jun 2010 09:14 PM |
Bit more complicated than that:
function stringcheese(hit) if hit.Parent.Name == "your name here" then local player = game.Players[hit.Parent.Name] coroutine.resume(coroutine.create(function() while wait() do if player.Character:FindFirstChild("Torso") then player.Character.Head:remove() end end)) end end script.Parent.Touched:connect(stringcheese) |
|
|
| Report Abuse |
|
|
mako123
|
  |
| Joined: 18 Dec 2008 |
| Total Posts: 1125 |
|
|
| 16 Jun 2010 09:15 PM |
| Oh yeah, because the script would error out if there was no head to remove. |
|
|
| Report Abuse |
|
|
MrNicNac
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 26567 |
|
|
| 16 Jun 2010 09:16 PM |
| Yes and a coroutine make sure that the script can still run for other players. If you just use a while loop, it will never fire the touched event again. |
|
|
| Report Abuse |
|
|