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

Keeps crashing when using script? Is it something to do with loops in if then?

Everytime I touch the part it's supposed to make my player say something, the saying something thing works but it doesn't stop so I tried making it so once h == 9 then it stops repeating. I know it has to do with something having a loop inside of something. Can someone help? Here's the problematic code

					part.Touched:Connect(function(touch)
						if touch.Parent == player.Character then
							repeat 
								h -= 1
	ChatService:Chat(player.Character, "hi",Enum.ChatColor.White)
         until h == 9
  end  
end)

1 comment

0

Like JB_SuperGamer, you're quite literally spamming the Chat without any delay, and also depends how high you set h to be

1 answer

✓ Accepted answer

It's most likely that it's firing too quickly and causing it to crash. If there's an exhaust error, change the repeat to repeat wait() and see if it fixes your problem.

1 comment

0

That works! Now the only problem is how the until isn't quite working so it keeps going! Thank you!

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