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

A very interesting question?

This is a very interesting problem cause the problem line isn't working and it doesn't give a error it automatically changes the color and the selected object value isn't even the button. I would appreciate any help.

local selected = script.Parent.Parent.selected.Value
    
local basecolor = Color3.fromRGB(177, 177, 177)
        
          
        
if script.Parent.name.MouseButton1Click and selected == nil then -- the problem is this if and then
        
    wait()
        
    selected = script.Parent
        
    selected.BackgroundColor3 = Color3.fromRGB(177, 177, 233)
        
   else
        
    selected.BackgroundColor3 = basecolor
        
    wait()
        
    selected = nil
        
    selected.BackgroundColor3 = Color3.fromRGB(177, 177, 233) 
end

1 comment

0

I'm not sure why you are checking if MouseButton1Click exists, as it is an event

1 answer

On line 21, you set your variable to nil and then try to set the backgroundColor3 to it on line 23. Simply don't set it to nil, or change your variable names if they're conflicting.

2 comments

0

nope I did this too and it failed

0

local selected = script.Parent.Parent.selected.Value local basecolor = Color3.fromRGB(177, 177, 177) if script.Parent.name.MouseButton1Click and selected == nil then wait() selected = script.Parent selected.BackgroundColor3 = Color3.fromRGB(177, 177, 233) elseif script.Parent.name.MouseButton1Click then selected.BackgroundColor3 = basecolor wait() selected.BackgroundColor3 = Color3.fromRG

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