Scoreboard Issue!

hello everyone, I have an issue with my scoreboard for my fps. When anyone gets the first kill, the scoreboard doesn’t update until another kill happens. The score works nice (meaning they show the correct amount of kills) but the first kill doesn’t update the script. Any help? (sorry if it’s a bit wordy)

script:

local redteamplayers
local blueteamplayers

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		for i,v in pairs(redteam:GetPlayers()) do
			redteamplayers = v
		end
		for i,v in pairs(blueteam:GetPlayers()) do
			blueteamplayers = v
		end
		player:WaitForChild("leaderstats"):WaitForChild("Kills").Changed:Connect(function()
			local redteamscore = 0
			local blueteamscore = 0
			if player.Team == redteam then
				redteamscore = redteamscore + redteamplayers.leaderstats.Kills.Value 
			elseif player.Team == blueteam then
				blueteamscore = blueteamscore + blueteamplayers.leaderstats.Kills.Value 
			end
		end)
	end)
end)

with local redteamplayers and not local redteamplayers = the team?

well that just breaks the script

Why do redteamscore and blueteamscore get set to 0 after the Changed event and not prior?

when they get set 0 before the changed event, the score has a bug that the score multiplied and the other team’s score doesn’t work.

why dont you use humanoid.Died and check if the player died was blue team and then give points to red?

I’m a little confused as to what you are trying to do here. But, I think you are looping through all the players on each team and then trying to set all the players to that team’s variable. Instead, you loop through all the players on a team in a random order with each iteration the “teamplayers” variable is set to a random player. The result is that the variables for “all” the players on a team is just a random player on the team.

When you are setting the scores here you are just adding zero to a random player’s score on the red or blue team. It’s also unclear what happens with each team’s score after it’s calculated. Overall, I think you have more learning to do before attempting this.