Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't my code not working right?

I have a code that checks if the clicker is the teamcolor of the tycoon. This is to prevent other people clicking things on your tycoon. But, it doesn't work. I get no errors and neither does it work. Help?

wait(1)

for i, v in pairs(script.Parent.Buttons:GetChildren()) do
	if v:FindFirstChild("ClickDetector") then
		v.ClickDetector.MouseClick:connect(function(clicker)
			if clicker.TeamColor == "Bright blue" then
				script.Parent.Color.BrickColor = v.BrickColor
				script.Parent.Parent.Parent.DropColor.Value = v.BrickColor
			end
		end)
	end
end

1 answer

✓ Accepted answer

Since TeamColor is a BrickColor value, that's what you need to compare it to!

wait(1)

for i, v in pairs(script.Parent.Buttons:GetChildren()) do
    if v:FindFirstChild("ClickDetector") then
        v.ClickDetector.MouseClick:connect(function(clicker)
            if clicker.TeamColor == BrickColor.new("Bright blue") then
                script.Parent.Color.BrickColor = v.BrickColor
                script.Parent.Parent.Parent.DropColor.Value = v.BrickColor
            end
        end)
    end
end

1 comment

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.