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

i cant seem to change things in if/then commands?

Asked by
Kaput_0 44
4 years ago

I'm trying to change the color of a brick whether or not a boolean value is true or false and I will have separate scripts control the variable which will change the colors. but while testing by checking the value its wouldent work and the button wulold just stay black and neither of the colors. can anyone help?

if script.Parent.on.Value == true then
    script.Parent.Color = Color3.new(0, 255, 0)
end
if script.Parent.on.Value == false then
    script.Parent.Color = Color3.new(255, 0, 0)
end

1 answer

Log in to vote
0
Answered by
pwx 1581 Moderation Voter
4 years ago

Have you used a .Changed event to make sure it connects upon anything being changed within' the BoolValue?

If not, try:

script.parent.Changed:Connect(function()
    if script.Parent.on.Value == true then
            script.Parent.Color = Color3.new(0, 255, 0)
    end
    if script.Parent.on.Value == false then
            script.Parent.Color = Color3.new(255, 0, 0)
    end
end)
0
well it isent black anymore but it just stayed red Kaput_0 44 — 4y
0
Instead of Color3.new() use Color3.fromRGB() pwx 1581 — 4y
0
thanks that worked Kaput_0 44 — 4y
Ad

Answer this question