I need help to fix my GUI as the script is not functioning properly.
My aim is to make it so that the gui swaps transparencies every minute to make a lighting effect like on a police car for my new CAD system I am working on.
while true do
script.Parent.Reds.Visible = false
script.Parent.Blues.Visible = true
-- missing a wait causing it to instantly switch back
script.Parent.Reds.Visible = true
script.Parent.Blues.Visible = false
wait(1) -- just use task.wait(1)... lol
end
I am assuming that you want the objects to be visible for a certain amount of time, too. Don’t forget to add a task.wait(1) at the end!
Also, I recommend using the task library because the functions in it are more efficient to use.
Here is your script.
while true do
script.Parent.Reds.Visible = true
script.Parent.Blues.Visible = false
task.wait(1)
script.Parent.Reds.Visible = false
script.Parent.Blues.Visible = true
task.wait(1)
end
Keep in mind that while true loops can mess with how Roblox handles memory, and your game could get issues from that. Do you understand how people use debounce variables yet?
I believe task.spawn can work a little better. In this case, it’s just a tiny bit easier to write. Also, I don’t know if anything on a coroutine will solve garbage collection issues.