Hasli4

Untitled

Aug 12th, 2026
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1.  
  2. local part = script.Parent
  3. local textLabel = part:WaitForChild("SurfaceGui"):WaitForChild("TextLabel")
  4.  
  5. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  6. local CheckSecretCode = ReplicatedStorage:WaitForChild("CheckSecretCode")
  7.  
  8. -- Настройки
  9. local CODE_LENGTH = 8
  10.  
  11. -- Английские буквы + цифры
  12. local characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
  13.  
  14. -- Генерация случайного кода
  15. local function generateCode(length)
  16. local code = ""
  17.  
  18. for i = 1, length do
  19. local randomIndex = math.random(1, #characters)
  20. code = code .. string.sub(characters, randomIndex, randomIndex)
  21. end
  22.  
  23. return code
  24. end
  25.  
  26. -- Генерируем код
  27. local secretCode = generateCode(CODE_LENGTH)
  28.  
  29. -- Показываем его в TextLabel
  30. textLabel.Text = secretCode
  31.  
  32. -- Настройки TextLabel
  33. textLabel.Font = Enum.Font.Code
  34. textLabel.TextScaled = true
  35.  
  36. print("Сгенерированный код:", secretCode)
  37.  
  38. -- Проверка введённого игроком кода
  39. CheckSecretCode.OnServerEvent:Connect(function(player, enteredCode)
  40.  
  41. -- Убираем случайные пробелы по краям
  42. enteredCode = string.gsub(enteredCode, "^%s+", "")
  43. enteredCode = string.gsub(enteredCode, "%s+$", "")
  44.  
  45. -- Проверяем код
  46. local isCorrect = enteredCode == secretCode
  47.  
  48. -- Отправляем результат обратно игроку
  49. CheckSecretCode:FireClient(player, isCorrect)
  50.  
  51. end)
  52.  
Advertisement
Add Comment
Please, Sign In to add comment