|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 8022 |
|
|
| 17 Aug 2013 04:51 PM |
^ Get rekt
But y u pcallin er day |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 8022 |
|
|
| 17 Aug 2013 04:55 PM |
Wot dos pcall do? Robloxlocks wot |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
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
|
  |
| 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
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 8022 |
|
|
| 17 Aug 2013 11:10 PM |
| and makes sense...1/40 of the time |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 8022 |
|
|
| 17 Aug 2013 11:15 PM |
Wait
I need to be smarter qq |
|
|
| Report Abuse |
|
|