So I am making a computer thing. And it has a background that changes a decal every few seconds.
But whenever I have clicked the GUI Button clicked I want it to break. But there is no way that I know how to because the TicketButton.ClickDetector.MouseClick:Connect(function() is outside of the while true do loop.
Here is my code.
-- // Varibles
local ComputerScreen = game.Workspace.Computer.ComputerScreen
local Decal = game.Workspace.Computer.ComputerScreen.Decal
local TicketButton = game.Workspace.ComputerScreen.SurfaceGui.TicketButton
---------------------------------------------------------------------------------
-- // Script
while true do
game.Workspace.Computer.ComputerScreen.Decal.Texture = "http://www.roblox.com/asset/?id=4652375883"
wait(0.5)
game.Workspace.Computer.ComputerScreen.Decal.Texture = "http://www.roblox.com/asset/?id=4648289865"
wait(0.5)
game.Workspace.Computer.ComputerScreen.Decal.Texture = "http://www.roblox.com/asset/?id=4652374880"
end
TicketButton.ClickDetector.MouseClick:Connect(function()
game.Workspace.Computer.ComputerScreen.Decal.Texture = "http://www.roblox.com/asset/?id=0"
TicketButton.BackgroundTransparency = 0
TicketButton.TextTransparency = 0
end)
But whenever I do,
TicketButton.ClickDetector.MouseClick:Connect(function()
game.Workspace.Computer.ComputerScreen.Decal.Texture = "http://www.roblox.com/asset/?id=0"
TicketButton.BackgroundTransparency = 0
TicketButton.TextTransparency = 0
``break``
end)
It errors with a statement, "break statement must be inside a loop".
Is there any way to help me or fix this issue?
Sorry if I make no sense and or this is not even possible, I am a bit new to scripting. Ha! :D

2 comments
You could try to make a variable and do while varname do and instead of doing break just do varname = false
You cannot break a function with "break". Break is only for loops. However, you can create a variable and whether or not the function will run will depend on its value.