generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Kill Brick Help

Previous Thread :: Next Thread 
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
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 is not online. 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
WindGuardian is not online. WindGuardian
Joined: 04 Jun 2011
Total Posts: 5246
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
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
21 Jan 2013 09:38 AM
It looks like my book is faulty, thanks.
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
21 Jan 2013 09:43 AM
Oops my output says that the 2nd script is faulty.
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
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 is not online. 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 is not online. 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
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
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
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
21 Jan 2013 12:03 PM
Lol OK.
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
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 is not online. 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
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
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 is not online. 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
UnequaledDonovan1 is not online. UnequaledDonovan1
Joined: 28 Oct 2012
Total Posts: 3909
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image