264 подписчика
-- Создаём основной ScreenGui
local screenGui = Instance.new("ScreenGui")
screenGui.Name = "MoneyDisplay"
screenGui.Parent = script.Parent
-- Создаём главный Frame (панель)
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, 200, 0, 50)
frame.Position = UDim2.new(1, -210, 0, 10) -- Прижат к правому верхнему углу
frame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
frame.BackgroundTransparency = 0.2
frame.BorderSizePixel = 0
frame.Parent = screenGui
-- Добавляем скругление углов (опционально)
local corners = Instance.new("UICorner")
corners.CornerRadius = UDim.new(0, 8)
corners.Parent = frame
-- Текст "Ваш баланс:"
local label = Instance.new("TextLabel")
label.Size = UDim2.new(0.5, 0, 1, 0)
label.Position = UDim2.new(0, 5, 0, 0)
label.BackgroundTransparency = 1
label.Text = "💰 Баланс:"
label.TextColor3 = Color3.fromRGB(255, 255, 255)
label.TextXAlignment = Enum.TextXAlignment.Left
label.Font = Enum.Font.GothamBold
label.TextSize = 18
label.Parent = frame
-- Поле для отображения суммы денег
local moneyText = Instance.new("TextLabel")
moneyText.Size = UDim2.new(0.5, -10, 1, 0)
moneyText.Position = UDim2.new(0.5, 0, 0, 0)
moneyText.BackgroundTransparency = 1
moneyText.Text = "0"
moneyText.TextColor3 = Color3.fromRGB(255, 215, 0) -- Золотой цвет
moneyText.TextXAlignment = Enum.TextXAlignment.Right
moneyText.Font = Enum.Font.GothamBold
moneyText.TextSize = 18
moneyText.Parent = frame
-- Ждём загрузки игрока
local player = game.Players.LocalPlayer
-- Функция обновления GUI
local function updateMoneyDisplay()
-- Ищем деньги в Leaderstats
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local cash = leaderstats:FindFirstChild("Cash") or leaderstats:FindFirstChild("Money") or leaderstats:FindFirstChild("Coins")
if cash then
moneyText.Text = tostring(cash.Value)
return
end
end
-- Если нет Leaderstats, пробуем найти IntValue в самом игроке
local playerMoney = player:FindFirstChild("Money") or player:FindFirstChild("Cash")
if playerMoney and playerMoney:IsA("IntValue") then
moneyText.Text = tostring(playerMoney.Value)
return
end
-- Если ничего не нашли
moneyText.Text = "N/A"
end
-- Первоначальное обновление
updateMoneyDisplay()
-- Функция для отслеживания изменений
local function onMoneyChanged(property)
if property == "Value" then
updateMoneyDisplay()
end
end
-- Подключаем обновление при изменении значения
local function setupTracking()
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local cash = leaderstats:FindFirstChild("Cash") or leaderstats:FindFirstChild("Money") or leaderstats:FindFirstChild("Coins")
if cash then
cash.Changed:Connect(onMoneyChanged)
return
end
end
local playerMoney = player:FindFirstChild("Money") or player:FindFirstChild("Cash")
if playerMoney and playerMoney:IsA("IntValue") then
playerMoney.Changed:Connect(onMoneyChanged)
end
end
setupTracking()
-- Если Leaderstats или деньги появятся позже (динамически)
player.ChildAdded:Connect(function(child)
if child.Name == "leaderstats" then
child.ChildAdded:Connect(function(stat)
if stat.Name == "Cash" or stat.Name == "Money" or stat.Name == "Coins" then
stat.Changed:Connect(onMoneyChanged)
updateMoneyDisplay()
end
end)
setupTracking()
updateMoneyDisplay()
elseif (child.Name == "Money" or child.Name == "Cash") and child:IsA("IntValue") then
child.Changed:Connect(onMoneyChanged)
updateMoneyDisplay()
end
end)
2 минуты
29 марта