Найти в Дзене
264 подписчика

-- LocalScript (поместить в StarterGui или в любой ScreenGui)


local Players = game:GetService("Players")
local player = Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats") -- Убедись, что у игрока есть leaderstats с монетами (Coins)

local screenGui = Instance.new("ScreenGui")
screenGui.Name = "BuyCharacterGui"
screenGui.Parent = player:WaitForChild("PlayerGui")

local button = Instance.new("TextButton")
button.Size = UDim2.new(0, 200, 0, 50)
button.Position = UDim2.new(0.5, -100, 0.5, -25)
button.Text = "Купить персонажа за 100 монет"
button.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
button.TextColor3 = Color3.fromRGB(0, 0, 0)
button.Parent = screenGui

button.MouseButton1Click:Connect(function()
local coins = leaderstats:FindFirstChild("Coins")
if coins and coins.Value >= 100 then
-- Запрос на сервер для покупки
local remote = Instance.new("RemoteEvent")
remote.Name = "BuyCharacterRequest"
remote.Parent = player
remote:FireServer()
-- Временно меняем текст кнопки
button.Text = "Персонаж куплен!"
button.BackgroundColor3 = Color3.fromRGB(255, 255, 0)
task.wait(2)
button.Text = "Купить персонажа за 100 монет"
button.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
else
button.Text = "Недостаточно монет!"
button.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
task.wait(2)
button.Text = "Купить персонажа за 100 монет"
button.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
end
end)
1 минута