|
| 07 Sep 2017 11:12 AM |
I am trying to make a brick kill a player when it is touched, but it only targets the player name the is in the code, if any other person steps on it it wont work. here is the script i am using:
local workspace = script.Parent.Parent local part = script.Parent
part.touched:connect(function () script.Parent.Parent.xxBlockMaster66xx.Humanoid.Health = (0) end)
If my bro logs in with his acct it doesn't kill him. |
|
|
| Report Abuse |
|
|
|
| 07 Sep 2017 11:19 AM |
part.Touched:connect(function(s) if s.Parent:findFirstChild("Humanoid") then s.Parent.Humanoid.Health = 0 end end)
|
|
|
| Report Abuse |
|
|
systemise
|
  |
| Joined: 04 Nov 2009 |
| Total Posts: 349 |
|
|
| 07 Sep 2017 11:21 AM |
The touched method passes whatever part triggered it as the first argument,
script.Parent.Touched:connect(function(touchedPart) if touchedPart.Parent:FindFirstChild("Humanoid") --To make sure the part is a limb. touchedPart.Parent.Humanoid:TakeDamage(100) end end) |
|
|
| Report Abuse |
|
|
systemise
|
  |
| Joined: 04 Nov 2009 |
| Total Posts: 349 |
|
| |
|
|
| 07 Sep 2017 11:23 AM |
^^ you forgot "then" after that if statement. :P
|
|
|
| Report Abuse |
|
|
WXBZ
|
  |
| Joined: 10 Oct 2012 |
| Total Posts: 850 |
|
|
| 07 Sep 2017 11:28 AM |
@systemise
I suggest replacing humanoid checking with player checking as then if something that isn't a player, that isn't supposed to die won't die.
if (game:GetService"Players":FindFirstChild(touchedPart.Parent.Name)) then
#code local function IsAuthorSmart(msg) if (msg:match(":connect")) then return false; else return true; end; end; if (IsAuthorSmart(thread)) then print "nice!"; end; |
|
|
| Report Abuse |
|
|
systemise
|
  |
| Joined: 04 Nov 2009 |
| Total Posts: 349 |
|
|
| 07 Sep 2017 11:29 AM |
| Nice catch, I wasn't thinking while typing it out in the post. |
|
|
| Report Abuse |
|
|
systemise
|
  |
| Joined: 04 Nov 2009 |
| Total Posts: 349 |
|
|
| 07 Sep 2017 11:30 AM |
| His use case didn't specify it being used exclusively to kill players, so I decided to use a less expensive method. Sue me. |
|
|
| Report Abuse |
|
|