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

My script keeps repeating itself when im in the game?

Asked by 5 years ago

I wrote a script for my camping game, i wrote the text talking and i was done with the script. It was fine until it started repeating everytime and i didn't know how to make it stop.

while true do script.Parent.Text = "Hello and welcome to The Forest!" wait(5) script.Parent.Text = "We are gonna have the most amazing night ever here! Right guys?" wait(5) script.Parent.Text = "Anyways, lets start our big journey!" end

1
Remove while true do end, you basically have this in an infinite loop. User#24403 69 — 5y
0
You placed a while loop, obviously it's gonna repeat itself. So just remove it. SoftlockedUnderZero 668 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago

It repeats because you have your code within an infinite loop (while true do), to make it not repeat just remove the loop

script.Parent.Text = "Hello and welcome to The Forest!" 
wait(5) 
script.Parent.Text = "We are gonna have the most amazing night ever here! Right guys?" wait(5) 
script.Parent.Text = "Anyways, lets start our big journey!"
0
you could even add a once a player joins to make it do everytime a player joins RobloxGameingStudios 145 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Such a simple question to answer, simply remove the 'while true do' while true do makes the script below it repeat itself over and over and over... Unless you place a 'break'

while true do
script.Parent.Text = "Hello and welcome to The Forest!" 
wait(5) 
script.Parent.Text = "We are gonna have the most amazing night ever here! Right guys?" 
wait(5) 
script.Parent.Text = "Anyways, lets start our big journey!
break
end

the break will end the loop:

break

But a easy solution to make it only play once is to just put your code usually:

script.Parent.Text = "Hello and welcome to The Forest!" 
wait(5) 
script.Parent.Text = "We are gonna have the most amazing night ever here! Right guys?" wait(5) 
script.Parent.Text = "Anyways, lets start our big journey!

you could also put a if player joins script to make it happen every time, but i wont put that here.

Answer this question