On update functions, or a better way of detecting updates?
Hello! I am trying to make a script, in the player's starter gui, which detects their kills, and adds it to their team's score. I need to make sure this only happens when their kills change, because if I don't, it will constantly add to the team's score.
03 | kos = script.Parent.Parent.leaderstats.KOs.Value |
05 | if script.Parent.Parent.leaderstats.KOs.Value ~ = kos then |
06 | teamc = script.Parent.Parent.TeamColor |
07 | if teamc = = BrickColor.new( "Bright blue" ) then |
09 | game.Teams.Blue.Score = game.Teams.Blue.Score + script.Parent.Parent.leaderstats.KOs.Value |
10 | elseif teamc = = BrickColor.new( "Bright red" ) then |
12 | game.Teams.Red.Score = game.Teams.Red.Score + script.Parent.Parent.leaderstats.KOs.Value |
13 | elseif teamc = = BrickColor.new( "Bright green" ) then |
15 | game.Teams.Green.Score = game.Teams.Green.Score + script.Parent.Parent.leaderstats.KOs.Value |
16 | elseif teamc = = BrickColor.new( "Bright yellow" ) then |
18 | game.Teams.Yellow.Score = game.Teams.Yellow.Score + script.Parent.Parent.leaderstats.KOs.Value |
This is what I have, and it doesn't work. The problem seems to be that the KOs value is always equal to their stat, but I want it to be equal to their stat at that time, so I can test their most recent stat to see if it has changed. Thanks in advance :)