So basically, I have a player whose team is Red. And then there's a soldier whose team is also Red. In this short script I want to compare the teams. I tested this script in team Red and right clicked on this soldier and for some reason it does not print out "Selected by same team!" And it DOES print out for print(hitterTeam) and print(soldierTeam) Red. And it also prints out "false" for print(selected). I wanna know why hitterTeam is not equal to soldierTeam.
humanoid = script.Parent soldier = humanoid.Parent soldierTeam = soldier.Team.Value --This is red cd = soldier.ClickDetector local selected cd.RightMouseClick:connect(function(hitter) local hitterTeam = hitter.Team print(hitterTeam) print(soldierTeam) while selected == false do print(selected) wait() if hitterTeam == soldierTeam then print("Selected by same team!") selected = true end end end)
For more context, questions will be answered!
Also... even without the while loop, it would still not work!
soldierTeam appears to be a nil value and are not defined, hitterTeam is indexed, they are two different values and are not equal to each other.
Okay for the people who don't understand yet. player.Team refers to game.Teams.[team the player is in] . So, it's not a string but a thing.