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.

2 comments
I know how to loop a script but not with functions
Basically I want the script to loop when you press the button