|
| 16 Dec 2014 05:52 PM |
Hiya! I'm trying to find a good kill function.. so when a player touches a "death brick" they die instantly. I have tried the normal function but I find the player can jump off the brick and not die if they jump instantly, or it sometimes doesn't work. This is the simple script I have made..
function onTouched(ht) ht:BreakJoints() end
script.Parent.Touched:connect(onTouched)
But this only gets rid of the part that touched it. So if a player's arm touches it, only the arm is removed, not the entire player. Is there a way that I can easily fix this?
Note: This is for an obby game I'm making. Trying to get a good kill script before I get too far into things! |
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
| |
|
|
| 16 Dec 2014 05:55 PM |
| @above ht is for the function.. I don't believe changing it to .Humanoid will affect that? Anyone else know? Thanks for the response however I appreciate it :) |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2014 05:55 PM |
if hum and hum.Parent then local plr = game.Players:getPlayerFromCharacter(hum.Parent) if not plr or (plr and plr.TeamColor == player.TeamColor) then local dis = (barrel.CFrame.p-hitPos).Magnitude local damage = killDamage if hitPart.Name=="Head" then damage=damage elseif hitPart.Name=="Torso" or hitPart.Name=="HumanoidRootPart" then if hitPart.Position.Y-hitPos.Position.Y>=0 then damage=damage*.9 else damage=damage*.8 end elseif string.Find(hitPart.Name,"Arm") or string.Find(hitPart.Name,"Leg") then if hitPart.Position.Y-hitPos.Position.Y>=0 then damage=damage*.5 else damage=damage*.2 end end damage = -0.000006*dis^2+damage if damage<=5 then damage=5 end hum:TakeDamage(damage) end end |
|
|
| Report Abuse |
|
|
025110
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 57661 |
|
|
| 16 Dec 2014 05:56 PM |
yes but you're using ht as a parameter
you need to get the humanoid and subtract it's HP |
|
|
| Report Abuse |
|
|
LucasLua
|
  |
| Joined: 18 Jun 2008 |
| Total Posts: 7386 |
|
|
| 16 Dec 2014 05:56 PM |
replace ht with ht.Parent.
This will break the joints of every part within the same parent as ht. |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2014 06:03 PM |
@joey that didn't really work.. and yes however this is kind of a different function.. and @above for some odd reason it works once but then doesn't work afterwards!
Thanks for responses :) |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 16 Dec 2014 06:19 PM |
here...
script.Parent.Touched:connect(function(hit) h = hit.Parent:findFirstChild("Humanoid") if h ~= nil then h.Parent:BreakJoints() end end) |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2014 06:20 PM |
I'm pretty sure that the issue is that Touched doesn't always fire correctly with short (duration) collisions.
--ThatChristianGuy |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 16 Dec 2014 06:37 PM |
| It's not that. It's because of Roblox's network model, meaning Touched events don't always fire if the part's behaviour was modified from the client (For example, the player) |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2014 06:41 PM |
| Set the bricks collide to false, making the player not able to jump off of it. They will fall into the brick, and wont be able to jump |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2014 06:46 PM |
| Thanks for the responses guys :) Well thats a bummer.. but I wonder how other obby's work so well! |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2014 07:43 PM |
What if you used the client to detect collisions then?
--ThatChristianGuy |
|
|
| Report Abuse |
|
|
Vatrain
|
  |
| Joined: 04 Mar 2014 |
| Total Posts: 4214 |
|
| |
|
|
| 16 Dec 2014 08:41 PM |
Vatrain cant script, ignore him.
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then hit.Parent:BreakJoints() elseif hit.Parent.Parent:FindFirstChild("Humanoid") then hit.Parent.Parent:BreakJoints() end end) |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 16 Dec 2014 08:59 PM |
| Why don't you jutdownload a fm of a kill block, look at the script in the block and use that and say it's your own |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 16 Dec 2014 10:11 PM |
This might solve the problem, in light of the local movement thing. LocalScript in StarterGui.
repeat wait() until game.Players.LocalPlayer.Character
for i, v in pairs(game.Players.LocalPlayer:children()) do if v:IsA("BasePart") then v.Touched:connect(function(hit) if hit.Name == "KillPart" then game.Players.LocalPlayer.Character.Humanoid.Health = 0 end end) end end
--ThatChristianGuy |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2014 10:12 PM |
for i, v in pairs(game.Players.LocalPlayer.Character:children()) do -- silly me if v:IsA("BasePart") then v.Touched:connect(function(hit) if hit.Name == "KillPart" then game.Players.LocalPlayer.Character.Humanoid.Health = 0 end end) end end
--ThatChristianGuy |
|
|
| Report Abuse |
|
|
|
| 17 Dec 2014 04:51 PM |
| Thanks for responses! Chistian guy, I will try that out! And thank you for other suggestions I'm gunna try them out now! |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 17 Dec 2014 05:01 PM |
Eh do it the other way Christian. Connecting to the player fires too many times.
function Iter(o) for k,v in pairs(o:GetChildren()) do if v.Name == "KillBrick" then v.Touched:connect(function(p) if p.Parent == game.Players.LocalPlayer.Character then -- Do yourself a favour and cache that p.Parent:BreakJoints() end end) end Iter(v) end end Iter(workspace) |
|
|
| Report Abuse |
|
|