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

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

Asked by 2 years ago

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)
0
Like JB_SuperGamer, you're quite literally spamming the Chat without any delay, and also depends how high you set `h` to be Shawnyg 4330 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

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.

0
That works! Now the only problem is how the until isn't quite working so it keeps going! Thank you! darkkitten12345 8 — 2y
Ad

Answer this question