Hasli4

Untitled

Jul 26th, 2026
9
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  3.  
  4. local player = Players.LocalPlayer
  5. local playerGui = player:WaitForChild("PlayerGui")
  6.  
  7. local remote = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("ChooseCharacter")
  8. local characterData = require(ReplicatedStorage:WaitForChild("CharacterData"))
  9.  
  10. local guiTemplate = ReplicatedStorage:WaitForChild("CharacterSelectGui")
  11. local gui = guiTemplate:Clone()
  12. gui.Name = "CharacterSelectGui"
  13. gui.ResetOnSpawn = false
  14. gui.Enabled = true
  15. gui.Parent = playerGui
  16.  
  17. print("CharacterSelectClient started")
  18.  
  19. local mainFrame = gui:WaitForChild("MainFrame")
  20. local cardsFolder = mainFrame:WaitForChild("Cards")
  21.  
  22. local function setupCard(card)
  23. if not card:IsA("Frame") then
  24. return
  25. end
  26.  
  27. local characterId = card:GetAttribute("CharacterId")
  28. if typeof(characterId) ~= "string" then
  29. warn("У карточки " .. card.Name .. " нет атрибута CharacterId")
  30. return
  31. end
  32.  
  33. local data = characterData[characterId]
  34. if not data then
  35. warn("Нет данных в CharacterData для: " .. characterId)
  36. return
  37. end
  38.  
  39. local imageLabel = card:FindFirstChild("ImageLabel")
  40. local nameLabel = card:FindFirstChild("NameLabel")
  41. local descriptionLabel = card:FindFirstChild("DescriptionLabel")
  42. local selectButton = card:FindFirstChild("SelectButton")
  43.  
  44. if imageLabel and imageLabel:IsA("ImageLabel") then
  45. imageLabel.Image = data.Image
  46. end
  47.  
  48. if nameLabel and nameLabel:IsA("TextLabel") then
  49. nameLabel.Text = data.DisplayName
  50. end
  51.  
  52. if descriptionLabel and descriptionLabel:IsA("TextLabel") then
  53. descriptionLabel.Text = data.Description
  54. end
  55.  
  56. if selectButton and selectButton:IsA("TextButton") then
  57. selectButton.Activated:Connect(function()
  58. print("Button clicked:", characterId)
  59. gui.Enabled = false
  60. remote:FireServer(characterId)
  61. end)
  62. end
  63. end
  64.  
  65. for _, card in ipairs(cardsFolder:GetChildren()) do
  66. setupCard(card)
  67. end
  68.  
  69. cardsFolder.ChildAdded:Connect(setupCard)
Advertisement
Add Comment
Please, Sign In to add comment