how come this code doesn’t work? when the game script gets to this point the output says stack end instead of continuing the script.
repeat wait() until game.StarterPlayer.StarterCharacterScripts.CheckIfPlayerIsInArea2.Value == true
how come this code doesn’t work? when the game script gets to this point the output says stack end instead of continuing the script.
repeat wait() until game.StarterPlayer.StarterCharacterScripts.CheckIfPlayerIsInArea2.Value == true
Can you send the full error/what the output says. Take a screenshot of it.
Here, perhaps try a few alternatives.
repeat wait(0.05) until game.StarterPlayer.StarterCharacterScripts.CheckIfPlayerIsInArea2.Value == true
while (game.StarterPlayer.StarterCharacterScripts.CheckIfPlayerIsInArea2.Value == false) do end
Or, with a wait() period,
while (game.StarterPlayer.StarterCharacterScripts.CheckIfPlayerIsInArea2.Value == false) do wait(0.05) end
game.StarterPlayer.StarterCharacterScripts.CheckIfPlayerIsInArea2.Changed:Connect(function(newValue)
if newValue == true then
-- Do whatever you wanted to, that was below the loop in your example
end
end)
I tried all of those and they didn’t work, although if I put it in a different code it works. Can it only be at the start of the code?
code that doesn’t work:
getRandomPlayer()
CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),"Let's split up to cover more ground.")
repeat wait() until game.StarterPlayer.StarterCharacterScripts.CheckIfPlayerIsInArea2.Value == true
getRandomPlayer()
CreateDialogueEvent:FireAllClients(getPlayerImage(randomPlayerId),"it worked")
code that does work:
repeat wait() until game.StarterPlayer.StarterCharacterScripts.Area2.Value == true
script.Parent.Touched:connect(function(e)
if e.Name == "Head" and e.Parent.CheckIfPlayerIsInArea2.Value == false then
e.Parent.CheckIfPlayerIsInArea2.Value = true
print(e.Parent.CheckIfPlayerIsInArea2.Value)
end
end)
You can use the built-in function named “spawn” to create a new thread outside of the main thread.
spawn(function()
--code
end)
This way your entire script will not yield.
I’m assuming this checks if their in the designated area, I want to recommend checking out this useful module.
You can call a Instance | Roblox Creator Documentation event instead of repeating it. This is faster AND more reliable. It also won’t lag the game.
You posted this same question in another thread where you got tons of answers. Why haven’t you gone back and tried those instead of creating an entirely new thread about the same issue? You’re just gonna get the same answers.
Both of these things were already reiterated in your previous post about the exact same problem. If those solutions didn’t work, you should’ve replied to those people saying they didn’t work for you.