So I was making a verification-kinda thing in my obby game that when you guessed the correct code (random each server) in the chat you will teleport to the next level, and when you guessed it wrong you will die, and start over. But the script is not working, I tried multiple ways to fix it and it's still not working. I tried putting print functions to the script and there are no prints in the dev console. Here is the code:
local notDEBOUNCE = game.ReplicatedStorage.THETRUEANSWER.Value
while wait() do
notDEBOUNCE = game.ReplicatedStorage.THETRUEANSWER.Value
end
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
msg = string.lower(msg)
if msg == (string.lower(tostring(notDEBOUNCE))) then
if plr.SENDVERIFICATION.Value == true and plr.SENDVERIFICATION2.Value == true then
plr.SENDVERIFICATION.Value = false
plr.SENDVERIFICATION2.Value = true
plr.leaderstats.Stage.Value = 51
plr.Character.Humanoid.Health = 0
print("success!!")
end
else
if plr.SENDVERIFICATION.Value == true and plr.SENDVERIFICATION2.Value == true then
plr.SENDVERIFICATION.Value = false
plr.SENDVERIFICATION2.Value = true
plr.leaderstats.Stage.Value = 50
plr.Character.Humanoid.Health = 0
print("wrong!!")
end
end
end)
end)

4 comments
My man, how could you have forgotten the basic principle of a loop? Loops REPEAT code; your program is indefinitely stuck on the 4th line.
I do not see the need for that loop, either. Not to mention the name "notDEBOUNCE"...? Compare THETRUEANSWER directly.
Also I would suggest using camel case for your variable naming. It cleans things up a lot.
thx for the comments i didnt know loop could get stuck and repeat the whole code, im still at beginner level in coding. also i added the loop because i want the variable to update every second because it prints a blank when try to print the variable