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: How do I connect when a player dies?

Previous Thread :: Next Thread 
MightyWanderer is not online. MightyWanderer
Joined: 17 Jan 2011
Total Posts: 1110
22 Jan 2014 09:10 PM
I've tried using both CharacterRemoving and Humanoid.Died, but neither are working. Is that what I should be using, or is there a better way to call a function upon a player's death?

Report Abuse
MightyWanderer is not online. MightyWanderer
Joined: 17 Jan 2011
Total Posts: 1110
22 Jan 2014 09:27 PM
Bump.
Report Abuse
domorox17 is not online. domorox17
Joined: 06 Mar 2012
Total Posts: 1710
22 Jan 2014 09:43 PM
The event is indded humanoidhere.Died, and does work. What are ya trying to do?
Report Abuse
MightyWanderer is not online. MightyWanderer
Joined: 17 Jan 2011
Total Posts: 1110
22 Jan 2014 09:49 PM
I was just testing out to see if it worked.

game.Players.PlayerAdded:connect(function(player)
player.Character.Humanoid.Died:connect(function(humanoid)
print(player.Character.Name.." has died!")
end)
end)

Report Abuse
domorox17 is not online. domorox17
Joined: 06 Mar 2012
Total Posts: 1710
22 Jan 2014 09:50 PM
That should work fine... j use this event for leaderstats.
Report Abuse
MightyWanderer is not online. MightyWanderer
Joined: 17 Jan 2011
Total Posts: 1110
22 Jan 2014 09:57 PM
It doesn't work, that's my problem. And I will be needing to use this event later, I usually test out the event a few times to make sure I know how to use it the right way before I use it in a real script.

Report Abuse
domorox17 is not online. domorox17
Joined: 06 Mar 2012
Total Posts: 1710
22 Jan 2014 10:00 PM
Maybe do in a localscript in startergui

plr = game:GetService("Players").LocalPlayer
hum = plr.Character["Humanoid"]

hum.Died:connect(function()
m = Instance.new("Message",workspace)
m.Text = (plr.name.."has died")
wait(1.5)
m:remove()
end)

Report Abuse
Ekkoh is not online. Ekkoh
Joined: 22 Oct 2012
Total Posts: 524
22 Jan 2014 10:00 PM
Did it happen to work once? The problem is you only connected it once. You need to reconnect the Died event of the Humanoid every time the character respawns.

Game:GetService("Players").PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
char:WaitForChild("Humanoid").Died:connect(function()
print(plr.Name .. " has died.")
end)
end)
end)

"We can walk a million miles, and end up in the sea." - George Ragan aka Johnny 3 Tears
Report Abuse
Wakarimasu is not online. Wakarimasu
Joined: 12 Nov 2013
Total Posts: 1448
22 Jan 2014 10:00 PM
PlayerAdded does not fire in test/solo mode.
Report Abuse
domorox17 is not online. domorox17
Joined: 06 Mar 2012
Total Posts: 1710
22 Jan 2014 10:01 PM
@wak aye that is true as well.
Report Abuse
MightyWanderer is not online. MightyWanderer
Joined: 17 Jan 2011
Total Posts: 1110
22 Jan 2014 10:05 PM
Hm, your script is working. I guess I've been doing something wrong. Thanks!

Report Abuse
domorox17 is not online. domorox17
Joined: 06 Mar 2012
Total Posts: 1710
22 Jan 2014 10:05 PM
Not a problem.
Report Abuse
Ekkoh is not online. Ekkoh
Joined: 22 Oct 2012
Total Posts: 524
22 Jan 2014 10:05 PM
I believe ChildAdded does though. I'd just change it back to PlayerAdded when you're going to publish it.

"We can walk a million miles, and end up in the sea." - George Ragan aka Johnny 3 Tears
Report Abuse
domorox17 is not online. domorox17
Joined: 06 Mar 2012
Total Posts: 1710
22 Jan 2014 10:06 PM
Instead of printing i use messages to test in an online server.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
22 Jan 2014 10:08 PM
game.Players.PlayerAdded:connect(function(player)
player.Character.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
print(player.Character.Name.." has died!")
end)
end)
end)
Report Abuse
MightyWanderer is not online. MightyWanderer
Joined: 17 Jan 2011
Total Posts: 1110
22 Jan 2014 10:08 PM
Wak, PlayerAdded does fire in test/solo mode.

Report Abuse
Wakarimasu is not online. Wakarimasu
Joined: 12 Nov 2013
Total Posts: 1448
22 Jan 2014 10:08 PM
What I do to test playeradded scripts in solo

Change the player variable to script.Parent.Parent
Put the script in starterpack

Test the game in solo. If it works, then change it back to whatever it was then leave it.
Report Abuse
domorox17 is not online. domorox17
Joined: 06 Mar 2012
Total Posts: 1710
22 Jan 2014 10:08 PM
@cnt he already used mine and it worked. Although, your would probably work too.
Report Abuse
Wakarimasu is not online. Wakarimasu
Joined: 12 Nov 2013
Total Posts: 1448
22 Jan 2014 10:09 PM
Mighty, it doesnt e3e
Report Abuse
Wakarimasu is not online. Wakarimasu
Joined: 12 Nov 2013
Total Posts: 1448
22 Jan 2014 10:09 PM
http://wiki.roblox.com/index.php/PlayerAdded_(Event)
Report Abuse
MightyWanderer is not online. MightyWanderer
Joined: 17 Jan 2011
Total Posts: 1110
22 Jan 2014 10:16 PM
I use PlayerAdded in solo mode.... o3o

Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
22 Jan 2014 10:16 PM
It sometimes works, depending on how slow your player loads
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