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)
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.