|
| 21 Jan 2013 09:31 AM |
This script is supposed to kill the Player when he/she touches the brick the script is inside. What went wrong with this?
function onTouch(Brick)
local Player = Brick.Parent:findFirstChild("Humanoid") if(Player ~= nil) then Player.Health = 0
end
script.Parent.Touched:connect(onTouch)
|
|
|
| Report Abuse |
|
|
megaguy44
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 1066 |
|
|
| 21 Jan 2013 09:33 AM |
script.Parent.Touched:connect(function(Hit) if (game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)) then Hit.Parent:BreakJoints() end end)
print('Hello World!') |
|
|
| Report Abuse |
|
|
|
| 21 Jan 2013 09:34 AM |
function onTouch(Brick)
db = false
local Player = Brick.Parent:FindFirstChild("Humanoid") if (Player ~= nil) and db == false then db = true Player:BreakJoints() wait(0.5) db = false
end
script.Parent.Touced:connect(onTouch)
MY PRECIOUS!!! |
|
|
| Report Abuse |
|
|
|
| 21 Jan 2013 09:38 AM |
| It looks like my book is faulty, thanks. |
|
|
| Report Abuse |
|
|
|
| 21 Jan 2013 09:43 AM |
| Oops my output says that the 2nd script is faulty. |
|
|
| Report Abuse |
|
|
|
| 21 Jan 2013 09:45 AM |
| But thanks to the 2nd script, I fixed it a little bit and now it works. |
|
|
| Report Abuse |
|
|
megaguy44
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 1066 |
|
|
| 21 Jan 2013 09:47 AM |
My script is more efficient, why not use it?
print('Hello World!') |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 21 Jan 2013 09:48 AM |
| I like mega's, because in the off chance Humanoid in named something else, you can still kill that person. + much simpler. |
|
|
| Report Abuse |
|
|
|
| 21 Jan 2013 09:52 AM |
WindGuardian's script uses debounce, when the only function it does is kill the person, in which debounce is really useless. Plus, it can kill zombies, NPC's, and others that have a humanoid...
While mega's is more efficient. It will kill only the player that touches it, ignoring zombies, NPC's, etc, and not much work was done to it, with max productivity.
*Recommends using megas... ^.^
~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ 【▬】 |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Jan 2013 12:06 PM |
| Oh, but I want to use the 2nd script because I want it to kill everything. I'm using it in an arena game, but ok. Thank you for da help. |
|
|
| Report Abuse |
|
|
Eddy3D
|
  |
| Joined: 21 Nov 2010 |
| Total Posts: 3017 |
|
|
| 21 Jan 2013 12:08 PM |
Another kill brick script:
function h(hit) f = h.Parent:findFirstChild("Humanoid") if (f~=nil) then f.Health = 0 end
script.Parent.Touched:connect(h)
I'm Superman ~(/'-')/ |
|
|
| Report Abuse |
|
|
|
| 21 Jan 2013 12:19 PM |
@Eddy
Missing an end.
You don't need parenthesis, nor "~= nil" because that's basically meaning it's true. Truthiness....
It's fine with " if f then " because it basically means " if f == true then ".
f.Health = 0 isn't always efficient, if certain models have a humanoid, it won't fall apart.
It's much shorter to write it with an anonymous function.
Not a good kill brick script.
~Critic.
~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ 【▬】 |
|
|
| Report Abuse |
|
|
megaguy44
|
  |
| Joined: 28 Sep 2008 |
| Total Posts: 1066 |
|
|
| 21 Jan 2013 12:22 PM |
-- *cough* script.Parent.Touched:connect(function(Hit) for _, Obj in next, (Hit.Parent:GetChildren()) do if (Obj:IsA("Humanoid")) then Hit.Parent:BreakJoints() break end end end)
print('Hello World!') |
|
|
| Report Abuse |
|
|
|
| 21 Jan 2013 12:39 PM |
function kill_a_robloxian(hit) local human = hit.Parent:FindFirstChild("Humanoid") if human~=nil then human.Health = 0 end
Workspace.KillBrick.Touched:connect(kill_a_robloxian)
|
|
|
| Report Abuse |
|
|
Eddy3D
|
  |
| Joined: 21 Nov 2010 |
| Total Posts: 3017 |
|
|
| 21 Jan 2013 12:50 PM |
@johan Yea I missed an end and it still works
I'm Superman ~(/'-')/ |
|
|
| Report Abuse |
|
|