TeamColor is being detected just fine and is the same but is skipping the if statement

This is going to be a little hard to explain so I’ll try my best. I’m making a ready up script. So far I’ve separated both players (of the two player game) into two teams and I’m using that to separate the two players for ease of scripting. Both players have the same scripts and the scripts just change what they do based on the TeamColor.

Here’s the problem area:

script.Parent.MouseButton1Up:Connect(function()
	print(script.Parent.Parent.Parent.Parent.TeamColor)
	if script.Parent.Parent.Parent.Parent.TeamColor == "Medium stone grey" then

It prints the right TeamColor:
image

However the script acts as if the if statement was failed when it should be passed (As shown by the print.)

Here are the other resources if needed.

Full script here
script.Parent.MouseButton1Up:Connect(function()
	print(script.Parent.Parent.Parent.Parent.TeamColor)
	if script.Parent.Parent.Parent.Parent.TeamColor == "Medium stone grey" then
		if 	game.ServerStorage.PLR1READY.Value == true then
			game.ServerStorage.PLR1READY.Value = false
			script.Parent.Text = "READY UP"
			print("PLR1 NOT READY")
		else
			game.ServerStorage.PLR1READY.Value = true
			script.Parent.Text = "UNREADY"
			print("PLR1 READY")
		end
	end
	if script.Parent.Parent.Parent.Parent.TeamColor == "Black" then
		if 	game.ServerStorage.PLR2READY.Value == true then
			game.ServerStorage.PLR2READY.Value = false
			script.Parent.Text = "READY UP"
			print("PLR2 NOT READY")
		else
			game.ServerStorage.PLR2READY.Value = true
			script.Parent.Text = "UNREADY"
			print("PLR2 READY")
		end
	end
	if game.ServerStorage.PLR1READY.Value == true and game.ServerStorage.PLR2READY.Value == true then
		for i,v in pairs(game:GetDescendants("Players")) do
			if v.Name == "Starter" then
				v:Destroy()
			end
		end
	end
end)
Explorer will all relevant information

image

What is happening here?

You can’t edit values inside ServerStorage from a local script. Use remote events

You’re comparing the TeamColor to a string instead of a BrickColor.

2 Likes

It’s not a localscript and it’s put inside of the PlayerGui, which to my knowledge is able to be seen and edited server side. I’ve tested everything inside of the script and it works, it’s just the if statement being failed that’s the issue.

That makes sense, I’ll try this.

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