Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local player = Players.LocalPlayer
- local playerGui = player:WaitForChild("PlayerGui")
- local remote = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("ChooseCharacter")
- local characterData = require(ReplicatedStorage:WaitForChild("CharacterData"))
- local guiTemplate = ReplicatedStorage:WaitForChild("CharacterSelectGui")
- local gui = guiTemplate:Clone()
- gui.Name = "CharacterSelectGui"
- gui.ResetOnSpawn = false
- gui.Enabled = true
- gui.Parent = playerGui
- print("CharacterSelectClient started")
- local mainFrame = gui:WaitForChild("MainFrame")
- local cardsFolder = mainFrame:WaitForChild("Cards")
- local function setupCard(card)
- if not card:IsA("Frame") then
- return
- end
- local characterId = card:GetAttribute("CharacterId")
- if typeof(characterId) ~= "string" then
- warn("У карточки " .. card.Name .. " нет атрибута CharacterId")
- return
- end
- local data = characterData[characterId]
- if not data then
- warn("Нет данных в CharacterData для: " .. characterId)
- return
- end
- local imageLabel = card:FindFirstChild("ImageLabel")
- local nameLabel = card:FindFirstChild("NameLabel")
- local descriptionLabel = card:FindFirstChild("DescriptionLabel")
- local selectButton = card:FindFirstChild("SelectButton")
- if imageLabel and imageLabel:IsA("ImageLabel") then
- imageLabel.Image = data.Image
- end
- if nameLabel and nameLabel:IsA("TextLabel") then
- nameLabel.Text = data.DisplayName
- end
- if descriptionLabel and descriptionLabel:IsA("TextLabel") then
- descriptionLabel.Text = data.Description
- end
- if selectButton and selectButton:IsA("TextButton") then
- selectButton.Activated:Connect(function()
- print("Button clicked:", characterId)
- gui.Enabled = false
- remote:FireServer(characterId)
- end)
- end
- end
- for _, card in ipairs(cardsFolder:GetChildren()) do
- setupCard(card)
- end
- cardsFolder.ChildAdded:Connect(setupCard)
Advertisement
Add Comment
Please, Sign In to add comment