Kill value doesnt went up by 1

Hey developers so i ran into issue so im making a deathmatch system where each team have to win for example im in redteam and player in blueteam if i kill a player in blueteam it went up 1 in textlabel but the problem is it isnt went up by one heres the main script for deathmatch system:

local Time = game.ReplicatedStorage.Time
local BlueKill = game.ReplicatedStorage.BlueKill
local RedKill = game.ReplicatedStorage.RedKill
local Status = game.ReplicatedStorage.Status
local Teams = game:GetService("Teams")

local BlueTeam = 0
local RedTeam = 0

function TimeWait(TimeToWait)
	Time.Value = TimeToWait
	
	repeat
		wait(1)
		Time.Value -= 1
	until Time.Value < 1
end

game.Players.PlayerAdded:Connect(function(player)
	if Status.Value == "Round in progress" then
		if BlueTeam < RedTeam then
			BlueTeam += 1
			player.Team = Teams.Blue
			player.TeamColor = Teams.Blue.TeamColor
		elseif RedTeam < BlueTeam then
			RedTeam += 1
			player.Team = Teams.Red
			player.TeamColor = Teams.Red.TeamColor
		end
		
		wait(1)
		player:LoadCharacter()
	end
	
	player.CharacterAdded:Connect(function(character)
		character.Humanoid.Died:Connect(function()
			if character.Humanoid:FindFirstChild("creator") then
				local killer = character.Humanoid:FindFirstChild("creator").Value
				
				if killer.TeamColor == Teams.Blue.TeamColor then
					BlueKill.Value += 1
				else
					RedKill.Value += 1
				end
			end
		end)
	end)
end)

while true do
	BlueTeam = 0
	RedTeam = 0
	RedKill.Value = 0
	BlueKill.Value = 0
	
	for _,v in pairs(game.Players:GetChildren()) do
		v.Team = Teams.Neutral
		v.TeamColor = Teams.Neutral.TeamColor
	end
	
	wait(1)
	
	for _,v in pairs(game.Players:GetChildren()) do
		v:LoadCharacter()
	end
	
	Status.Value = "Intermission"
	TimeWait(20)
	
	if #game.Players:GetChildren() < 2 then 
		Status.Value = "Need More Players" 
		TimeWait(5)
	else
		Status.Value = "Round in progress"

		for _,v in pairs(game.Players:GetChildren()) do
			if BlueTeam <= RedTeam then
				BlueTeam += 1
				v.Team = Teams.Blue
				v.TeamColor = Teams.Blue.TeamColor

			elseif RedTeam < BlueTeam then
				RedTeam += 1
				v.Team = Teams.Red
				v.TeamColor = Teams.Red.TeamColor

			end
		end
		
		wait(1)
		
		for _,v in pairs(game.Players:GetChildren()) do
			v:LoadCharacter()
		end
		
		TimeWait(40)

		for _,v in pairs(game.Players:GetChildren()) do
			v.Team = Teams.Neutral
			v.TeamColor = Teams.Neutral.TeamColor
		end
		
		wait(1)
		
		for _,v in pairs(game.Players:GetChildren()) do
			v:LoadCharacter()
		end

		if BlueKill.Value > RedKill.Value then
			Status.Value = "Blue Win!"

		elseif RedKill.Value > BlueKill.Value then
			Status.Value = "Red Win!"

		else
			Status.Value = "Tie!"
		end

		TimeWait(5)
	end
end

text label script not client script:

while wait() do
	script.Parent:WaitForChild("BlueFrame").Kill.Text = game.ReplicatedStorage.BlueKill.Value
	script.Parent:WaitForChild("RedFrame").Kill.Text = game.ReplicatedStorage.RedKill.Value
	script.Parent.Status.Text = game.ReplicatedStorage.Status.Value
	script.Parent.Time.Text = game.ReplicatedStorage.Time.Value
end

if you thought this is easy im just a basic scripter.

1 Like

I think you should add condition that checks if round started or not, otherwise if you dont add it then it will start the round infinitely and the values will always reset to 0. I hope this will be helpful for you

1 Like

This might just be a useful topic.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.