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: I want to make a function if the player is dead

Previous Thread :: Next Thread 
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
12 Mar 2014 04:03 PM
for i, v in pairs(game.Players:getChildren()) do
local player = v.Character
if player.Humanoid.Health == 0 then
print("Someone died")
end
end

I tryed making this, but it doesnt work. Anyone know how do it?
Report Abuse
error9999 is not online. error9999
Joined: 05 Sep 2009
Total Posts: 1593
12 Mar 2014 04:08 PM
make an if statment for character, cause the first mini second after joining the script will work, but your player won't have a char yet.
Report Abuse
Duelingwarlord is not online. Duelingwarlord
Joined: 15 Feb 2010
Total Posts: 22333
12 Mar 2014 04:11 PM
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
print("plr died")
end)
end)
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
12 Mar 2014 04:12 PM
How?
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
12 Mar 2014 04:19 PM
Ok now i need a function when a player dies
Report Abuse
GRAGGER2001 is not online. GRAGGER2001
Joined: 05 Apr 2009
Total Posts: 2043
12 Mar 2014 04:25 PM
game.Players.PlayerAdded:connect(function(p)
p.CharacterAdded:connect(function(c)
c.Humanoid.Died:connect(function()
print(p.Name..' has died!')
end)
end)
end)
Report Abuse
error9999 is not online. error9999
Joined: 05 Sep 2009
Total Posts: 1593
12 Mar 2014 04:25 PM
humanoid:died

it is something like that
Report Abuse
Foxconn is not online. Foxconn
Joined: 20 Feb 2011
Total Posts: 275
12 Mar 2014 04:32 PM
There are two scripts here

First goes in workspace:

function addScript(player)
local die = script.PlayerDead:Clone()
die.Parent = player
die.Disabled = true
end
game.Players:ChildAdded:connect(addScript)



Second script: Name "PlayerDead" This script goes under the first.

function onDeath(player)
--your code
end
game.Workspace[script.Parent.Name].HumanoidDied:connect(onDeath)
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
12 Mar 2014 04:35 PM
Thx but ive already copied the other script
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
12 Mar 2014 04:37 PM
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
char.Humanoid.Died:connect(function()
c = char.Head:Clone()
c.Name = TheOtherHead
c.Parent = Workspace
end)
end)
end)

I made this script and it should clone the players head. I know it wont spawn at the players position. But this script doesnt work. The poput said "string expected"
Report Abuse
error9999 is not online. error9999
Joined: 05 Sep 2009
Total Posts: 1593
13 Mar 2014 12:32 AM
c.Name = "TheOtherHead"
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
13 Mar 2014 12:41 AM
game.Players.PlayerAdded:connect(function(plr)
print("Player Has Joined")
plr.CharacterAdded:connect(function(char)
print("Character has loaded")
char.Humanoid.Died:connect(function(ded)
print("Character has died")
end) end) end)
Report Abuse
wubbzy301 is not online. wubbzy301
Joined: 15 May 2010
Total Posts: 1188
13 Mar 2014 12:45 AM
USE .Died (Event) THEN!

function cmonstepitup()
-- UR code HEre, ITS SANIC TIME
end

HUMANOID.Died:connect(cmonstepitup)
Report Abuse
wubbzy301 is not online. wubbzy301
Joined: 15 May 2010
Total Posts: 1188
13 Mar 2014 12:46 AM
:Died (Event)
sorry!!!
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
13 Mar 2014 02:20 PM
Thx, i will try making a death script similar to the ragdoll death script
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
13 Mar 2014 02:24 PM
-_-
Does noone realize how easy this is???

--LocalScript,in StarterGui
StarterGui
-LocalScript


--TheCode

plr = game.Players.LocalPlayer
repeat wait() until plr.Character
c = plr.Character
repeat wait() until c.Humanoid.Health == 0
--dostuff


--4 lines of code to do it..
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
13 Mar 2014 02:29 PM
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
char.Humanoid.Died:connect(function()
c = char.Head:Clone()
c.Name = "TheOtherHead"
c.Parent = Workspace
c.CFrame = char.Head.CFrame
char.Head:Remove()
t = char.Torso:Clone()
t.Name = "TheOtherTorso"
t.Parent = Workspace
t.CFrame = char.Torso.Cframe
char.Torso:Remove()
end)
end)
end)

Ok i tryed this script and it really works. Now i need to weld the TheOtherHead and the TheOtherTorso
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
13 Mar 2014 02:32 PM
Try:
char:MakeJoints()
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
13 Mar 2014 02:33 PM
Oh wait,you set the parent of other things to workspace..

Make a new model,and parent the fakehead and torso to the model,and then
Model:MakeJoints()
Report Abuse
Supasamsonic is not online. Supasamsonic
Joined: 01 Dec 2013
Total Posts: 81
13 Mar 2014 02:44 PM
Put this in a localscript inside startergui

local player = script.Parent.Parent

local char = player.Character

char.Humanoid.Changed:connect(function()

if char.Humanoid.Health == 0 then
print("player dead")
end
end)
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
14 Mar 2014 01:16 PM
Ok but how do i make a model and the fake torso and head inside it?
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
14 Mar 2014 01:36 PM
Right after
"char.Humanoid.Died:connect(function()"
Add
M = Instance.new("Model",Workspace) M.Name = char.Name

And then parent the fake head and torso to M

And then after u clone the head and torso,and set their parent to "M"
M:MakeJoints()
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
14 Mar 2014 01:37 PM
So
c.Parent = M
t.Parent = M
M:MakeJoints()
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
14 Mar 2014 01:52 PM
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
char.Humanoid.Died:connect(function()
m = Instance.new("Model",Workspace)
m.Name = char.Name
c = char.Head:Clone()
c.Name = "TheOtherHead"
c.Parent = m
c.CFrame = char.Head.CFrame
char.Head:Remove()
t = char.Torso:Clone()
t.Name = "TheOtherTorso"
t.Parent = m
t.CFrame = char.Torso.Cframe
char.Torso:Remove()
end)
end)
end)

Ok so do i add m:MakeJoints()?
Report Abuse
masterjosue1998 is not online. masterjosue1998
Joined: 21 Feb 2011
Total Posts: 949
14 Mar 2014 02:14 PM
help plz
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