Any way to break this loop from RunService.Heartbeat?

So, the behavior I’m seeing is that it’s never toggling off to the default state, but resets once you click it again

can you send a video about it?

Absolutely! (I used my mouse cursor to guide what I’m watching for)

Here:

so i’m assuming you need it to check when its set to false

and another thing i need to tack on is a way to break the loop when the player closes the gui

Nahh it’s alright if it keeps running if the gui gets closed

edit: also yes, when the call script fires “false” or “true” is what I’m looking to use as the toggle

Try this

while true do
	if IsGradient == true then
		animate()
	else
		gradchange.Color = (GradientPresets["Default"])			
		gradchange2.Color = (GradientPresets["Default"])
	end
	wait()
end

Also attach a video of the results if you can please

Will do!

This one yielded interesting results

I have a feeling we actually fixed that line and we actually just have more problems to solve in the script itself I could be wrong though

Mm maybe, but this block is the only thing that’s involved with this particular function.

hmm I think we need to break the loop after the button was pressed again since its then just creating multiple loops controlling it

try this

while true do
	BreakLoop = false
	if IsGradient == true then
		animate()
	else
		gradchange.Color = (GradientPresets["Default"])			
		gradchange2.Color = (GradientPresets["Default"])
	end
	IsGradientEvent.OnServerEvent:Connect(function()
		BreakLoop = true
	end)
	if BreakLoop == true then
		break
	end
	wait()
end

It yields the same results as the previous video, however I found if I do a while true loop in the task.create(function(), it does loop the animation. But I can’t think of a way to leave that loop once the conditions change.

do

if IsGradient == false then
	break
end

put that in the loop

I tried that, I don’t think it liked me very much when I did it.

thats a shame I cant think of much else but it might come to me later

1 Like

Yeah that’s been pretty much the stage in development on this script that I’ve been in for the past week.

I’ve stumped all my friends with it so far lol

This is a fairly random question but would you like to see some of the stuff I have been working on

Absolutely

I would not mind at all.

whipping together a video right now

I Also Made The Game L-Mod If You Want To Check That Out

1 Like