There are no errors listed in the output and it doesn't print out line 16.(the last line of this part). The Player's TeamColor is the same as name.Name:sub(4) which is "BtnBright green". This is only PART of the script.
function FindName() for i,v in pairs(Workspace:GetChildren()) do for i,a in pairs(v:GetChildren()) do if a:FindFirstChild("ClickDetector") then print(a) return a end end end end local player = script.Parent.Parent.Parent.Parent script.Parent.MouseButton1Down:connect(function() local name = FindName() print(name) -- Works until next line if name.Name:sub(4) == player.TeamColor then print(name.."!") -- Does not show?
Please note that this is only part of the script.
So what exactly are you trying to acomplish... It seems that the sub might mess things up. Or it may be that it's not matching the player.TeamColor, I suggest doing this:
function FindName() for i,v in pairs(Workspace:GetChildren()) do for i,a in pairs(v:GetChildren()) do if a:FindFirstChild("ClickDetector") then print(a) return a end end end end local player = script.Parent.Parent.Parent.Parent script.Parent.MouseButton1Down:connect(function() local name = FindName() print(name) -- Works until next line if name.Name:sub(4) == player.TeamColor then print(name.."!") -- Does not show? elseif name.Name:sub(4) ~= player.TeamColor then print('False') end end)
This will allow you to see if it even goes past the if, if not then the IF is incorrect.
It may also be that since both for loops use "i" as an index, the script may be getting confused. It's worth a shot anyways.
Just replace the first "for i,v" with "for _,v" and see if it does anything differently.