Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I made script with the function that I want to go loop. How do I do this?

Asked by 6 years ago

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.

0
I know how to loop a script but not with functions Pizza64X 8 — 6y
0
Basically I want the script to loop when you press the button ShadowNinja1080 6 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

Ad

Answer this question