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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Values are being spammed.

Previous Thread :: Next Thread 
FreddyFazbearx is not online. FreddyFazbearx
Joined: 04 Dec 2011
Total Posts: 271
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
FreddyFazbearx is not online. FreddyFazbearx
Joined: 04 Dec 2011
Total Posts: 271
14 Jan 2015 09:21 AM
Bump...I dunno how to fix it.
Report Abuse
parkiet3 is not online. parkiet3
Joined: 16 Jul 2011
Total Posts: 832
14 Jan 2015 09:36 AM
Do wait(1) instead of wait()
Report Abuse
FreddyFazbearx is not online. FreddyFazbearx
Joined: 04 Dec 2011
Total Posts: 271
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 is not online. 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
FreddyFazbearx is not online. FreddyFazbearx
Joined: 04 Dec 2011
Total Posts: 271
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
FreddyFazbearx is not online. FreddyFazbearx
Joined: 04 Dec 2011
Total Posts: 271
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
FreddyFazbearx is not online. FreddyFazbearx
Joined: 04 Dec 2011
Total Posts: 271
14 Jan 2015 10:30 AM
Bumper.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
FreddyFazbearx is not online. FreddyFazbearx
Joined: 04 Dec 2011
Total Posts: 271
14 Jan 2015 10:48 AM
Works like a charm Jarod, sorry I'm still learning. Thanks for you help.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
14 Jan 2015 11:08 AM
No problem. The Died even is just more reliable, at least I would think so.
Report Abuse
FreddyFazbearx is not online. FreddyFazbearx
Joined: 04 Dec 2011
Total Posts: 271
14 Jan 2015 11:09 AM
Seems that way. It's not spamming any more :)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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