debounce = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
if debounce then
return
end
debounce = true
local plr = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent)
local gui = script.Parent:FindFirstChild("codegui") -- Make sure the GUI is named correctly
if gui then
local randomNumber = math.random(100, 999)
print(randomNumber)
gui.Frame.code.Text = randomNumber
print(randomNumber)
local clone = gui:Clone()
clone.Parent = plr:FindFirstChild("PlayerGui")
wait(3.5)
local enteredCode = tostring(plr.PlayerGui:FindFirstChild("codegui"):FindFirstChild("Frame"):FindFirstChild("entercode").Text)
print(enteredCode)
if enteredCode == randomNumber then
plr.PlayerGui.codegui:Destroy()
else
plr.Character.Humanoid.Health = 0
end
else
print("GUI not found.")
end
end
wait()
debounce = false
end)
Im trying to make a system where if you enter a correct code it gets rid of your gui, I have tried using string.find but that just comes up with nothing but works for both incorrect and correct things, but if I compare it to the number to check if its right then it kills the player no matter what
(its saying what I put in the text box is nil)
** You are now Level 1! **