"Comment" Text Wont Change

  1. What do you want to achieve? Keep it simple and clear!

I was making a system where if i win it will show a comment of victory rate, if the score is under 3 and over 1 its victory if its under 5 and over 3 its flawless victory,
yes it is gui thing.

  1. What is the issue? Include screenshots / videos if possible!

the comment text wont change on score even though i change the values to 4 it wont change, instead it still says “Victory” not “Flawless Victory”.

Heres The Code

local Comment = script.Parent

Event.OnClientEvent:Connect(function(TotalRedScore, TotalBlueScore)

	if player.Team == game.Teams.RedTeam or game.Teams.RedTeamOther and TotalRedScore > TotalBlueScore then

		if TotalRedScore >= 1 and TotalRedScore <= 3 then
			Comment.Text = "VICTORY"
		end

		if TotalRedScore >= 3 and TotalRedScore <= 5 then
			Comment.Text = "FLAWLESS VICTORY"
		end
		
	elseif player.Team == game.Teams.BlueTeam or game.Teams.BlueTeamOther and TotalRedScore < TotalBlueScore then
			if TotalBlueScore >= 1 and TotalBlueScore <= 3 then
			Comment.Text = "VICTORY"
			end

			if TotalBlueScore >= 3 and TotalBlueScore <= 5 then
			Comment.Text = "FLAWLESS VICTORY"
		end
	end
end)
1 Like

What is the “Comment” variable? Try printing TotalBlueScore or TotalRedScore and see what values it prints.

the comment is a textlabel in a gui

Try debugging your code with prints then.

Event.OnClientEvent:Connect(function(TotalRedScore, TotalBlueScore)
   print(TotalRedScore);
   print(TotalBlueScore);
-- etc...
end);

If the output says they are lower than 3 or higher than 5 it means there’s something wrong with how you’re changing the values or sending them

it printed out the same score i set, nothings wrong.

How about printing something after the ifs. I’ve never seen an if set up with that or.

Instead of

if player.Team == game.Teams.RedTeam or game.Teams.RedTeamOther

Try with

if player.Team == game.Teams.RedTeam or player.Team == game.Teams.RedTeamOther

Same for blue team.

and make sure to enclosed it with parentheses before adding and TotalRedScore > TotalBlueScore

1 Like
local Comment = script.Parent
local player = game.Players.LocalPlayer

Event.OnClientEvent:Connect(function(TotalRedScore, TotalBlueScore)
	if player.Team == game.Teams.RedTeam or player.Team ==  game.Teams.RedTeamOther and TotalRedScore > TotalBlueScore then
		Comment.Text = TotalRedScore <= 3 and "VICTORY" or TotalRedScore > 3 and "FLAWLESS VICTORY"
	elseif player.Team == game.Teams.BlueTeam or player.Team ==  game.Teams.BlueTeamOther and TotalRedScore < TotalBlueScore then
		Comment.Text = TotalBlueScore <= 3 and "VICTORY" or TotalBlueScore > 3 and "FLAWLESS VICTORY"
	end
end)

Cleaned up your code and fixed it.

what if the total score is 0? it would still count as VICTORY

local Comment = script.Parent
local player = game.Players.LocalPlayer

Event.OnClientEvent:Connect(function(TotalRedScore, TotalBlueScore)
	if player.Team == game.Teams.RedTeam or player.Team ==  game.Teams.RedTeamOther and TotalRedScore > TotalBlueScore then
		if TotalRedScore > 0 then
			Comment.Text = TotalRedScore <= 3 and "VICTORY" or TotalRedScore > 3 and "FLAWLESS VICTORY"
		end
	elseif player.Team == game.Teams.BlueTeam or player.Team ==  game.Teams.BlueTeamOther and TotalRedScore < TotalBlueScore then
		if TotalBlueScore > 0 then
			Comment.Text = TotalBlueScore <= 3 and "VICTORY" or TotalBlueScore > 3 and "FLAWLESS VICTORY"
		end
	end
end)

Then OP or I can fix it.

it isnt working, no errors no warning.

This is what you need to do:

local Teams = game:GetService("Teams")

local Comment = script.Parent

Event.OnClientEvent:Connect(function(TotalRedScore, TotalBlueScore)

	if TotalRedScore > TotalBlueScore then -- First check which Team won
		if player.Team == Teams.RedTeam or player.Team == Teams.RedTeamOther then -- Check if player is in the winning Team
			if TotalRedScore >= 1 and TotalRedScore < 3 then
				Comment.Text = "VICTORY"
			elseif TotalRedScore >= 3 and TotalRedScore <= 5 then
				Comment.Text = "FLAWLESS VICTORY"
			end
		end
	else -- Blue Team won the round
		if player.Team == Teams.BlueTeam or player.Team == Teams.BlueTeamOther then
			if TotalBlueScore >= 1 and TotalBlueScore < 3 then
				Comment.Text = "VICTORY"
			elseif TotalBlueScore >= 3 and TotalBlueScore <= 5 then
				Comment.Text = "FLAWLESS VICTORY"
			end
		end
	end
end)

You can’t do both <= 3 and >= 3 when checking if the score is within a range, plus you were accidentally running both if statements after each other so they were interfering with the result

it didnt work i dont even know why

What method are you using to set the scores?

Edit: @How4rdy This place file should help explain what you need to do: VictoryGuiExample.rbxl (59.0 KB)

The score is randomly generated every 1 second

oh nvm its because i have alot of if statements that i didnt put it in the right spot

1 Like

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