im making a tutorial and want to go to the next information only when the previous info was used, in this case til the user clicks a cube, but every time it gets to that point and i click the cube, studio stops responding for a little bit and it says "game script timeout" and just doesnt work. it was fine and worked well til i added the "repeat" part
local text = "To start, Left Click the cube." game.Workspace.Map.TutorialRestriction.Invis1.CanCollide = false script.Parent.Tutorial.Click.Playing = true for i = 1, #text do script.Parent.Tutorial.Gui.TextLabel.Text = string.sub(text, 1, i) wait(0.0625) end if text == "To start, Left Click the cube." then script.Parent.Tutorial.Click.Playing = false repeat if game.Workspace.Interactables.Cube.Anchored == false then script.Parent.Tutorial6.Disabled = true end until script.Parent.Tutorial6.Disabled == false end
It's probably because you're not yielding during that repeat loop.
This should be enough to fix it.
local function disable() if not game.Workspace.Interactables.Cube.Anchored then script.Parent.Tutorial6.Disabled = true end end repeat disable(); wait() until script.Parent.Tutorial6.Disabled == false
--ps: just rearranged it a bit to look nicer