Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

GUI/Message for my game not functioning?

repeat
wait (1)
while wait (1) do 
if script.Disabled == false then
script.Parent.Text = game.Workspace.Sound.Name
end
end
until script.Disabled == true

It only changes the text once, any ideas on how to make it repeat forever? And can anyone give me a script I can copy?

1 comment

0

@Magic I would but to me the way I'm doing it is way easier, not the best scripter

2 answers

#What you could do? Use a while loop. This loop's purpose is to loop infinitely until it's false or broken.


#While Loops While loops are most commonly seen in this form: while true do because the code you put between the while and do acts like an if statement. If we can add a wait like you do, the loop will run every time the wait is over.

while wait() do end --wait() is the statement.

We can do actual full if then statements in between while and do:

while workspace.Part.BrickColor == BrickColor.new(1) do end --Works as long as workspace.Part is white

After the statement is false the loop will never run again. You need to use a function or something like that to use it again.


#Final Product

while wait(1) do --When the script is disabled, all code in the script stops.
	script.Parent.Text = workspace.Sound.Name
end

##Version 2

--If you want to make the loop stop after something happens then:
local a = true
while wait(1) do
	if a then
		script.Parent.Text = workspace.Sound.Name
	else
		break --replace a with anything you want. When a is false, the loop will be broken.
	end
end


Hope it helps!

You don't need a "game.Workspace.Sound.Name". Instead, you should use the "" prefix.

This discussion is preserved as it was. New answers, comments, and votes are closed.