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

How Can I Turn A Model From Bright Bluish Green To Bright Orange And Back With One Button?

Asked by
jacobwow 140
10 years ago

To turn my Base1 item all into the same color i use this script in a button:

function onTouch(part)
    local humanoid = part.Parent:FindFirstChild("Humanoid") 
    if (humanoid ~= nil) then
        for i,v in pairs(game.Workspace.Base1:GetChildren()) do
        v.BrickColor = BrickColor.new(106)
end
    end
end

script.Parent.Touched:connect(onTouch)

But I want to change it to orange, then if i touch it again i want it to be teal/ bright bluish green

1 answer

Log in to vote
0
Answered by 10 years ago
var1 = true
function onTouch(part)
    local humanoid = part.Parent:FindFirstChild("Humanoid")
    if humanoid ~= nil then
        if var1 == true then
            wait(.5)
            for i, v in pairs(game.Workspace.Base1:GetChildren()) do
                v.BrickColor = BrickColor.new("Bright red") --Whatever color you want it to change inside the parenthesis
            end
            var1 = false
        elseif var1 == false then
            wait(.5)
            for i, v in pairs(game.Workspace.Base1:GetChildren()) do
                v.BrickColor = BrickColor.new("Bright blue") --Whatever color you want it to change second inside the parenthesis
            end
            var1 = true
        end
    end
end
script.Parent.Touched:connect(onTouch)

Hope this helped!

Ad

Answer this question