Hi, I am new to scripting and usually get help from the wiki but I could not find anything for this topic. Basically, I am trying to create a screen gui that when you press the button once the brick changes it's colour from Medium stone grey to Pastel yellow and the material also changes to neon. Then I want it when I press it again it changes back. I am terrible at scripting and I could not find much on the web, please help me. I had done multiple scripts before but deleted them, this was the one I was working on now:
lit = game.Workspace.IFE_1.yela thevariable = 5 if thevariable<bob then script.Parent.MouseButton1Click:connect(function() lit.BrickColor = BrickColor.new("Pastel yellow") lit.Material = "Neon" bob = 6 wait(3) bob = 1 end) --I thought what was happening was that it ran -- the code back straight after but I added a wait -- and nothing happened. if thevariable>1 then lit.BrickColor = BrickColor.new("Medium stone grey") lit.Material = "Plastic" end end
Another code: _____________________________
local lit = game.Workspace.IFE_1.yela local on = true function on() on = true lit.BrickColor = BrickColor.new("Pastel yellow") lit.Material = "Neon" print(lit.BrickColor) print(lit.Material) end function off() on = false lit.BrickColor = BrickColor.new("Pastel yellow") lit.Material = "Neon" print(lit.BrickColor) print(lit.Material) end function onClick() if on == true then on() elseif on == false then off() end end excuse my noobiness :) thanks in advance.
You can only use clicking functions and mouse filters on Button type of objects if you're making GUIs
debounce = false Button.MouseButton1Click:connect(function() --Locate part if debounce == false then part.Material = "New material" part.BrickColor = BrickColor.new("New color") debounce = true else part.Material = "Old material" part.BrickColor = BrickColor.new("Old color") debounce = false end end)