Найти в Дзене
-- Script (поместить в ServerScriptService) local Players = game:GetService("Players") local function setupPlayer(player) local remote = Instance.new("RemoteEvent") remote.Name = "BuyCharacterRequest" remote.Parent = player remote.OnServerEvent:Connect(function(plr) if plr ~= player then return end local leaderstats = player:FindFirstChild("leaderstats") local coins = leaderstats and leaderstats:FindFirstChild("Coins") if coins and coins.Value >= 100 then coins.Value -= 100 -- Здесь замени "CharacterTemplate" на имя твоего персонажа в ReplicatedStorage или Workspace local characterTemplate = game.ReplicatedStorage:FindFirstChild("CharacterTemplate") if characterTemplate then local newCharacter = characterTemplate:Clone() newCharacter.Parent = workspace newCharacter.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame + Vector3.new(0, 3, 0) -- Можно выдать игроку возможность управлять персонажем -- player.Character = newCharacter -- Осторожно: заменит текущего персонажа else warn("Не найден CharacterTemplate в ReplicatedStorage") end end end) end Players.PlayerAdded:Connect(setupPlayer) -- Для уже существующих игроков for _, player in ipairs(Players:GetPlayers()) do setupPlayer(player) end
2 месяца назад
-- 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)
2 месяца назад
-- СКРИПТ МАГАЗИНА (поместить в ServerScriptService) local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") -- Создаём RemoteEvent для связи сервера с клиентом local remoteEvent = Instance.new("RemoteEvent") remoteEvent.Name = "ShopRemoteEvent" remoteEvent.Parent = ReplicatedStorage -- === НАСТРОЙКИ МАГАЗИНА === local shopItems = { { itemName = "Зелье здоровья", price = 50, description = "Восстанавливает 50 HP", icon = "rbxassetid://1234567890", -- замените на свой ID itemType = "heal", healAmount = 50 }, { itemName = "Меч", price = 150, description = "Увеличивает урон", icon = "rbxassetid://1234567890", itemType = "sword" }, { itemName = "Ключ", price = 100, description = "Открывает секретную дверь", icon = "rbxassetid://1234567890", itemType = "key" } } -- === ФУНКЦИЯ ПОКУПКИ === local function purchaseItem(player, itemIndex) local item = shopItems[itemIndex] if not item then warn("Товар не найден") return false end local leaderstats = player:FindFirstChild("leaderstats") if not leaderstats then return false end local money = leaderstats:FindFirstChild("Money") if not money then return false end if money.Value >= item.price then -- Списываем монеты money.Value = money.Value - item.price -- Выдаём предмет (настраиваем под свои нужды) giveItemToPlayer(player, item) print(player.Name .. " купил " .. item.itemName .. " за " .. item.price .. " монет") return true else print(player.Name .. " не хватает монет для покупки " .. item.itemName) return false end end -- === ФУНКЦИЯ ВЫДАЧИ ПРЕДМЕТА === local function giveItemToPlayer(player, item) -- Пример: кладём предмет в Backpack или в специальный папку if item.itemType == "heal" then -- Восстановление здоровья local character = player.Character if character then local humanoid = character:FindFirstChildWhichIsA("Humanoid") if humanoid then humanoid.Health = math.min(humanoid.MaxHealth, humanoid.Health + item.healAmount) end end elseif item.itemType == "sword" then -- Даём меч (создаём инструмент) local tool = Instance.new("Tool") tool.Name = item.itemName tool.RequiresHandle = false tool.Parent = player.Backpack elseif item.itemType == "key" then -- Сохраняем в IntValue, что у игрока есть ключ local keyValue = Instance.new("BoolValue") keyValue.Name = "HasKey" keyValue.Value = true keyValue.Parent = player end end -- === GUI ДЛЯ КНОПКИ ОТКРЫТИЯ МАГАЗИНА === local function createShopButton(player) local screenGui = Instance.new("ScreenGui") screenGui.Name = "ShopButtonGUI" screenGui.Parent = player:WaitForChild("PlayerGui") -- Кнопка открытия магазина local openButton = Instance.new("TextButton") openButton.Size = UDim2.new(0, 60, 0, 60) openButton.Position = UDim2.new(1, -80, 0, 10) openButton.BackgroundColor3 = Color3.fromRGB(255, 170, 0) openButton.Text = "🛒" openButton.TextSize = 30 openButton.Font = Enum.Font.GothamBold openButton.Parent = screenGui -- Закругление local corner = Instance.new("UICorner") corner.CornerRadius = UDim.new(0, 30) corner.Parent = openButton -- Открытие магазина при нажатии openButton.MouseButton1Click:Connect(function() remoteEvent:FireClient(player, "openShop", shopItems) end) end -- === СОЗДАНИЕ GUI МАГАЗИНА НА КЛИЕНТЕ === local function setupClientShop(player) local function createShopGui(items) -- Удаляем старый GUI, если есть local oldGui = player.PlayerGui:FindFirstChild("ShopGUI") if oldGui then oldGui:Destroy() end local shopGui = Instance.new("ScreenGui") shopGui.Name = "ShopGUI" shopGui.Parent = player.PlayerGui -- Фон local background = Instance.new("Frame") background.Size = UDim2.new(0, 400, 0, 500) background.Position = UDim2.new(0.5, -200, 0.5, -250) background.BackgroundColor3 = Color3.fromRGB(30, 30, 40) background.BackgroundTransparency = 0.1 background.BorderSizePixel = 0 background.Parent = shopGui local cornerBg = Instance.new("UICorner") cornerBg.CornerRadius = UDim.new(0, 15)
2 месяца назад
-- Разместите этот скрипт в ServerScriptService local Players = game:GetService("Players") -- Функция создания GUI для игрока local function createMoneyGUI(player) -- Создаём ScreenGui local screenGui = Instance.new("ScreenGui") screenGui.Name = "MoneyGUI" screenGui.Parent = player:WaitForChild("PlayerGui") -- Создаём основной Frame local frame = Instance.new("Frame") frame.Size = UDim2.new(0, 200, 0, 50) frame.Position = UDim2.new(0, 10, 0, 10) frame.BackgroundColor3 = Color3.fromRGB(30, 30, 30) frame.BackgroundTransparency = 0.2 frame.BorderSizePixel = 0 frame.Parent = screenGui -- Закругление углов (необязательно) local uiCorner = Instance.new("UICorner") uiCorner.CornerRadius = UDim.new(0, 10) uiCorner.Parent = frame -- Текст "Деньги:" local textLabel = Instance.new("TextLabel") textLabel.Size = UDim2.new(0, 80, 1, 0) textLabel.Position = UDim2.new(0, 10, 0, 0) textLabel.BackgroundTransparency = 1 textLabel.Text = "💰 Деньги:" textLabel.TextColor3 = Color3.fromRGB(255, 255, 255) textLabel.TextSize = 18 textLabel.Font = Enum.Font.GothamBold textLabel.TextXAlignment = Enum.TextXAlignment.Left textLabel.Parent = frame -- Значение денег (обновляется динамически) local moneyValue = Instance.new("TextLabel") moneyValue.Name = "MoneyValue" moneyValue.Size = UDim2.new(0, 90, 1, 0) moneyValue.Position = UDim2.new(0, 100, 0, 0) moneyValue.BackgroundTransparency = 1 moneyValue.Text = "0" moneyValue.TextColor3 = Color3.fromRGB(255, 215, 0) -- золотой moneyValue.TextSize = 18 moneyValue.Font = Enum.Font.GothamBold moneyValue.TextXAlignment = Enum.TextXAlignment.Right moneyValue.Parent = frame -- Функция обновления значения денег local function updateMoneyDisplay() local leaderstats = player:FindFirstChild("leaderstats") if leaderstats then local moneyStat = leaderstats:FindFirstChild("Money") if moneyStat then moneyValue.Text = tostring(moneyStat.Value) else moneyValue.Text = "0" end else moneyValue.Text = "0" end end -- Подписываемся на изменение значения Money local leaderstats = player:WaitForChild("leaderstats", 5) if leaderstats then local moneyStat = leaderstats:FindFirstChild("Money") if moneyStat then moneyStat:GetPropertyChangedSignal("Value"):Connect(updateMoneyDisplay) updateMoneyDisplay() end end -- Если leaderstats появится позже player.CharacterAdded:Connect(function() task.wait(0.5) updateMoneyDisplay() end) end -- Создаём leaderstats и Money, если их нет local function setupLeaderstats(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local money = Instance.new("IntValue") money.Name = "Money" money.Value = 1000 -- начальная сумма money.Parent = leaderstats end -- Обработка новых игроков Players.PlayerAdded:Connect(function(player) -- Добавляем leaderstats, если отсутствует if not player:FindFirstChild("leaderstats") then setupLeaderstats(player) end -- Даём время на создание leaderstats и создаём GUI task.wait(0.1) createMoneyGUI(player) end) -- Для уже существующих игроков (если скрипт добавили в середине игры) for _, player in pairs(Players:GetPlayers()) do if not player:FindFirstChild("leaderstats") then setupLeaderstats(player) end task.spawn(function() task.wait(0.1) createMoneyGUI(player) end) end
2 месяца назад
-- Скрипт для создания денег у игроков local Players = game:GetService("Players") local function setupLeaderstats(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local money = Instance.new("IntValue") money.Name = "Money" money.Value = 0 money.Parent = leaderstats end Players.PlayerAdded:Connect(setupLeaderstats) for _, player in pairs(Players:GetPlayers()) do setupLeaderstats(player) end
2 месяца назад
Если нравится — подпишитесь
Так вы не пропустите новые публикации этого канала