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 » Scripters
Home Search
 

Re: Better kill function

Previous Thread :: Next Thread 
forgetfulapple is not online. forgetfulapple
Joined: 13 Mar 2012
Total Posts: 98
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 is not online. 025110
Joined: 23 Nov 2012
Total Posts: 57661
16 Dec 2014 05:53 PM
ht.Humanoid?
Report Abuse
forgetfulapple is not online. forgetfulapple
Joined: 13 Mar 2012
Total Posts: 98
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
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
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 is not online. 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 is not online. 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
forgetfulapple is not online. forgetfulapple
Joined: 13 Mar 2012
Total Posts: 98
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 is not online. 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
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
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 is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
16 Dec 2014 06:22 PM
@The

true
Report Abuse
eLunate is not online. 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
lateregistration is not online. lateregistration
Joined: 02 Apr 2013
Total Posts: 2630
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
forgetfulapple is not online. forgetfulapple
Joined: 13 Mar 2012
Total Posts: 98
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
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
16 Dec 2014 07:43 PM
What if you used the client to detect collisions then?


--ThatChristianGuy
Report Abuse
Vatrain is not online. Vatrain
Joined: 04 Mar 2014
Total Posts: 4214
16 Dec 2014 08:12 PM
game.Players.NAME(Kill)
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
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
LittleFruitCake is not online. LittleFruitCake
Joined: 17 May 2013
Total Posts: 802
16 Dec 2014 08:58 PM
Vatrains irks perfectly.
Report Abuse
LittleFruitCake is not online. LittleFruitCake
Joined: 17 May 2013
Total Posts: 802
16 Dec 2014 08:58 PM
Works*
Report Abuse
LittleFruitCake is not online. LittleFruitCake
Joined: 17 May 2013
Total Posts: 802
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
Functionalized is not online. Functionalized
Joined: 28 Jul 2011
Total Posts: 3736
16 Dec 2014 09:31 PM
Why kill me?
Report Abuse
LittleFruitCake is not online. LittleFruitCake
Joined: 17 May 2013
Total Posts: 802
16 Dec 2014 09:34 PM
What.
Report Abuse
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
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
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
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
forgetfulapple is not online. forgetfulapple
Joined: 13 Mar 2012
Total Posts: 98
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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