DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
|
| 25 Feb 2014 02:39 PM |
Hi, I'm trying to make a certain sound stop when a player dies. I don't know what I did wrong so if anyone could correct me that'd be awesome. Thanks.
function died() game.Workspace.Chase:Stop() end game.Players:Died() |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2014 02:44 PM |
function stopSound() workspace.Chase:stop() end
function getPlayer() for _, plr in pairs (game.Players:GetChildren()) do repeat wait() until plr.Character plr.Character.Humanoid.Died:connect(stopSound) end end
game.Players.PlayerAdded:connect(getPlayer) |
|
|
| Report Abuse |
|
|
DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
|
| 25 Feb 2014 02:45 PM |
| Thanks, I'll have to see if it works later. |
|
|
| Report Abuse |
|
|
DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
| |
|
|
| 25 Feb 2014 04:20 PM |
| y u no post the output?!?! |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 25 Feb 2014 04:27 PM |
function plrDied(plr) print(plr.Name.. " kicked the bucket.") Workspace["Sound"]:Stop() end
game.Players.PlayerAdded:connect(function(plr) repeat wait() until plr.Character plr.Character:WaitForChild("Humanoid").Died:connect(function() plrDied(plr) end) plr.CharacterAdded:connect(function(c) c:WaitForChild("Humanoid").Died:connect(function() plrDied(plr) end) end) end) |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2014 04:29 PM |
| azrath... i think we have the same thing!!!! *rips hair |
|
|
| Report Abuse |
|
|
Azarth
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 25 Feb 2014 04:30 PM |
| Yours only fires for the first death. |
|
|
| Report Abuse |
|
|
| |
|
DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
|
| 25 Feb 2014 05:12 PM |
| Thanks, guys, but it still isn't working. It did print "Player 1 has kicked the bucket", however the music didn't stop. |
|
|
| Report Abuse |
|
|
DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
|
| 25 Feb 2014 05:19 PM |
I never thought it'd be this hard to use an event. I've tried to make the beginning of the script however it won't work game.Players:Died(function)players) |
|
|
| Report Abuse |
|
|
|
| 25 Feb 2014 05:25 PM |
Put this in workspace as a normal script, test it in start server/player mode:
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() game.Workspace.Chase:Stop() end) end) end)
When life gives you lemons... BURN HIS HOUSE DOWN! >:D |
|
|
| Report Abuse |
|
|
DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
|
| 25 Feb 2014 05:29 PM |
| It didn't work, but here's the output: "WaitForChild called on an Instance that is not in a DataModel." |
|
|
| Report Abuse |
|
|
DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
| |
|
DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
| |
|
DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
| |
|