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: KillBrick when clicked

Previous Thread :: Next Thread 
sunday1520 is not online. sunday1520
Joined: 23 Aug 2012
Total Posts: 693
17 Aug 2013 03:54 PM
How do i make a killbrick that kills whoever clicked it? I figured out how to find a specific player and have them killed, but i have not figured out how to make it so that whoever clicks it dies. Anyone know? Right now my script looks like this:

script.Parent.ClickDetector.MouseClick:connect(function()
game.Workspace.Player1.Humanoid.Health=0
end)

Works in a test server and finds player 1, but as i said it doesnt find whoever clicked it. So can i have some help?
Report Abuse
hunte922 is not online. hunte922
Joined: 28 May 2008
Total Posts: 6969
17 Aug 2013 03:56 PM
script.Parent.ClickDetector.MouseClick:connect(function(player)
if player.Character then
if player.Character:FindFirstChild("Humanoid") then
player.Character.Humanoid.Health=0
end
end
end)
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
17 Aug 2013 03:56 PM
script.Parent.ClickDetector.MouseClick:connect(function(guy) -- You have to create a variable. Duur.
game.Workspace.guyHumanoid.Health=0
end)
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
17 Aug 2013 03:57 PM
Hunte, whoever clicks it is PROBABLY a player with a character; unless the guy was deleted, of course.
Report Abuse
sunday1520 is not online. sunday1520
Joined: 23 Aug 2012
Total Posts: 693
17 Aug 2013 03:58 PM
Bebee, when you connect like that i dont need a paramater. Mine works perfectly fine in what it does. What the post above yours looks like is what i wanted. So thankyou! Ill try that out
Report Abuse
hunte922 is not online. hunte922
Joined: 28 May 2008
Total Posts: 6969
17 Aug 2013 03:59 PM
@Bebee
Your script you posted is horribly broken. I've never heard of guyHumanoid.
And the script I posted is to ensure it never breaks in case the character or humanoid are missing.
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
17 Aug 2013 04:02 PM
A. Text lag, I'm also playing a game. It types utterly slow and I have to keep pressing buttons over and over.


B. I know that, but I am saying that if a player is clicking it,
1. they probably have a character.
2.only players can click it.
Ofc, it is nice to be precautionary.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 Aug 2013 04:45 PM
The most simplest one:

script.Parent.MouseDetector.MouseClick:connect(function(x)
pcall(function() x.Character:BreakJoints() end)
end)
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
17 Aug 2013 04:51 PM
^
Get rekt

But y u pcallin er day
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 Aug 2013 04:52 PM
In case the noob is an exploiter and has been robloxlocked
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
17 Aug 2013 04:55 PM
Wot dos pcall do?
Robloxlocks wot
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 Aug 2013 04:56 PM
pcall just runs the script, and if there is an error, won't break it.

RobloxLocked is a __protected__ property.
Anything with a script context of less than 4 can not "use" or "index" it.
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
17 Aug 2013 06:22 PM
So like

pcall(function()

for i = 1, 6 do
print("hi")
wait( --didnt end it
end
end)


It would still run ?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 Aug 2013 06:25 PM
wat
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
17 Aug 2013 06:29 PM
'Runs the script, if theres an error, it wont break it.'

I said wait( instead of wait()

So im assuming itll work
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
17 Aug 2013 06:30 PM
No, you can't use wait's in pcall, you need to make it a ypcall or Spawn
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
17 Aug 2013 11:10 PM
and makes sense...1/40 of the time
Report Abuse
dmjoe is not online. dmjoe
Joined: 01 May 2009
Total Posts: 2387
17 Aug 2013 11:13 PM
Lol. Pcall is for checking if something exists without erroring when it doesn't. You could just as easily use a conditional to check, but pcall is more professional.

~Keep the Earth below my feet.~
Report Abuse
Infocus is not online. Infocus
Joined: 28 Apr 2011
Total Posts: 8022
17 Aug 2013 11:15 PM
Wait

I need to be smarter qq
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