|
| 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
|
  |
| 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 |
|
|
|
| 12 Mar 2014 04:11 PM |
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(char) print("plr died") end) end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Mar 2014 04:19 PM |
| Ok now i need a function when a player dies |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| Joined: 05 Sep 2009 |
| Total Posts: 1593 |
|
|
| 12 Mar 2014 04:25 PM |
humanoid:died
it is something like that |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 12 Mar 2014 04:35 PM |
| Thx but ive already copied the other script |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| Joined: 05 Sep 2009 |
| Total Posts: 1593 |
|
| |
|
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
|
  |
| 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
|
  |
| Joined: 15 May 2010 |
| Total Posts: 1188 |
|
| |
|
|
| 13 Mar 2014 02:20 PM |
| Thx, i will try making a death script similar to the ragdoll death script |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 14 Mar 2014 01:16 PM |
| Ok but how do i make a model and the fake torso and head inside it? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 14 Mar 2014 01:37 PM |
So c.Parent = M t.Parent = M M:MakeJoints() |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|