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

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

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

✓ Accepted answer

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)

3 comments

0

well it isent black anymore but it just stayed red

0

Instead of Color3.new() use Color3.fromRGB()

0

thanks that worked

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