|
| 14 Jan 2015 08:37 AM |
Right, I have a script here which determines what team gets a point after someone is killed. Now it all works fine but my values are being spammed so it doesn't just add 1 point, it adds a random amount between 30 and 50....Now I think it's the while loop, I did try a return but that just exits the loop and nothing happens after 1 player is killed. Probably not the best way of doing a script for this kind of thing but here it is.
while true do for _, player in pairs (game.Players:GetChildren()) do local Humanoid = player.Character.Humanoid if Humanoid.Health == 0 then print 'Confirmed: Humanoid health 0' local tag = Humanoid:findFirstChild("creator") if tag ~= nil then local killer = tag.Value if killer.Parent ~= nil then if killer.TeamColor == game.Teams["Team Red"].TeamColor then game.Workspace.RedKills.Value = game.Workspace.RedKills.Value + 1 --return The Return exits the function so it's no longer active after someone dies. elseif killer.TeamColor == game.Teams["Team Blue"].TeamColor then game.Workspace.BlueKills.Value = game.Workspace.BlueKills.Value + 1 --return The Return exits the function so it's no longer active after someone dies. end end end end end wait() end |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2015 09:21 AM |
| Bump...I dunno how to fix it. |
|
|
| Report Abuse |
|
|
parkiet3
|
  |
| Joined: 16 Jul 2011 |
| Total Posts: 832 |
|
|
| 14 Jan 2015 09:36 AM |
| Do wait(1) instead of wait() |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2015 09:37 AM |
| And what about when a player is killed right after another? Let's not forget this is for all the players...I guarantee it will still spam even if I change the wait time. |
|
|
| Report Abuse |
|
|
parkiet3
|
  |
| Joined: 16 Jul 2011 |
| Total Posts: 832 |
|
|
| 14 Jan 2015 09:40 AM |
| Kk didnt see just remove the creator after the points were added |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2015 09:41 AM |
| Okay, I'll see what happens. Thanks for the help. I'm assuming it will be assigned again when another player is killed? |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2015 09:47 AM |
| Well it seems to add values when the Humanoid is hit by the killer after it dies. Any idea on how to stop this? |
|
|
| Report Abuse |
|
|
| |
|
|
| 14 Jan 2015 10:39 AM |
game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Character) Character:WaitForChild("Humanoid").Died:connect(function() if Character.Humanoid:FindFirstChild("creator") then Killer = Character.Humanoid.creator.Value if Killer.Parent then if Killer.TeamColor == game.Teams["Team Red"].TeamColor then game.Workspace.RedKills.Value = game.Workspace.RedKills.Value + 1 else game.Workspace.BlueKills.Value = game.Workspace.BlueKills.Value + 1 end end end end) end) end) |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2015 10:48 AM |
| Works like a charm Jarod, sorry I'm still learning. Thanks for you help. |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2015 11:08 AM |
| No problem. The Died even is just more reliable, at least I would think so. |
|
|
| Report Abuse |
|
|
|
| 14 Jan 2015 11:09 AM |
| Seems that way. It's not spamming any more :) |
|
|
| Report Abuse |
|
|