Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't my code not working right?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
8 years ago

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

0
Thanks! UnGenericUser 20 — 8y
Ad

Answer this question