Hasli4

CharacterSelectLocalScript

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