I'm learning at scripting and I made function that I want to loop but how do I do this? I added while true do then the script ended up not working. What should I do?
local light = game.Workspace.Lights function onClicked() light.Sound:Play() light.Red.Material = "Neon" light.Blue.Material = "Plastic" light.Red.PointLight.Enabled = true light.Blue.PointLight.Enabled = false wait(0.5) light.Blue.Material = "Neon" light.Red.Material = "Plastic" light.Red.PointLight.Enabled = false light.Blue.PointLight.Enabled = true end script.Parent.TextButton.MouseButton1Down:connect(onClicked)
Basically I want the function to loop when you click the GUI that I made.
local light = game.Workspace.Lights function onClicked() while true do light.Sound:Play() light.Red.Material = "Neon" light.Blue.Material = "Plastic" light.Red.PointLight.Enabled = true light.Blue.PointLight.Enabled = false wait(0.5) light.Blue.Material = "Neon" light.Red.Material = "Plastic" light.Red.PointLight.Enabled = false light.Blue.PointLight.Enabled = true end end script.Parent.TextButton.MouseButton1Down:connect(onClicked)
if you want make a loop just add while true do.
ps: While true do can break you game , use a wait() on ALL LOOP SCRIPTS for dont break it.