Мне нужен скрипт, который выдает Gui на ощупь в Roblox? - PullRequest
0 голосов
/ 15 декабря 2010

Как сделать, чтобы скрипт вызывал графический интерфейс магазина при касании кирпича?

А как мне сделать "купить" вещи в магазине с графическим интерфейсом?

Ответы [ 3 ]

6 голосов
/ 05 декабря 2012

Вам нужно будет самостоятельно создать этот интерфейс магазина , но я дам вам скрипт "GUI Giver".Примечание: Вы должны поместить сценарий Внутри Кирпич / Часть.

local Gui = game.Lighting.GUI --Replace this with the location of your GUI

function GiveGui(Player)
if Player.PlayerGui:FindFirstChild(Gui.Name)~=nil then return end
Gui:Clone().Parent=Player.PlayerGui
end

script.Parent.Touched:connect(function(hit)

local Player=game.Players:GetPlayerFromCharacter(hit.Parent)
if Player==nil then return end
GiveGui(Player)

end)
2 голосов
/ 17 декабря 2010

Создайте сценарий, который соединяет событие кирпича «Touched» с функцией, которая использует метод игры «getPlayerFromCharacter». Игроки, чтобы найти игрока, затем вставляют графический интерфейс в PlayerGui игрока.Например:

function newGUI()
    --enter something that makes a shop GUI then at the end returns the 'ScreenGui' it's in.
end

script.Parent.Touched:connect(function(hit)
    local player = game.Players:getPlayerFromCharacter(hit.Parent);
    if player ~= nil then
        newGUI().Parent = player.PlayerGui;
    end
end)
0 голосов
/ 04 января 2013

Следующий код может использоваться, чтобы дать игроку графический интерфейс магазина:

local ShopGui = game.Lighting.ShopGui -- This should be the location of your gui
local ShopPart = workspace.ShopPart -- This should be the shop part

ShopPart.Touched:connect(function(hit)
    if hit.Parent == nil then return end
    if hit.Name ~= "Torso" then return end
    local Player = game.Players:playerFromCharacter(hit.Parent)
    if Player == nil then return end
    if _G[Player] == nil then _G[Player] = {} end
    if _G[Player].ShopGui == nil then
        _G[Player].ShopGui = ShopGui:Clone()
        _G[Player].ShopGui.Parent = Player.PlayerGui
    end
end)

ShopPart.TouchEnded:connect(function(hit)
    if hit.Parent == nil then return end
    local Player = game.Players:playerFromCharacter(hit.Parent)
    if Player == nil then return end
    if _G[Player] == nil then return end
    if _G[Player].ShopGui ~= nil then
        _G[Player].ShopGui:Destroy()
        _G[Player].ShopGui = nil
    end
end)

Обратите внимание, что "ShopPart" должен быть большой частью, которая покрывает всю площадь магазина (предпочтительно невидимую)

Затем вам также необходимо создать графический интерфейс магазина.

В графическом интерфейсе магазина необходимо создать текстовые кнопки (или кнопки изображений), каждый из которых содержит следующий скрипт:

local Cost = 100
local ThingToBuy = game.Lighting.Weapon -- Make sure this is right
script.Parent.MouseButton1Down:connect(function()
    local Player = script.Parent.Parent.Parent.Parent -- Make sure this is correct
    if Player.leaderstats["money"].Value >= Cost then -- Change "money" to anything you want (it     must be in the leaderstats tho)
        Player.leaderstats["money"].Value = Player.leaderstats["money"].Value - Cost
        ThingToBuy:Clone().Parent = Player.Backpack
        -- GuiToBuy:Clone().Parent = Player.PlayerGui
    end
end)

Кодне проверено, поэтому может содержать ошибки.И вам, возможно, придется изменить больше вещей, чем упомянуто.Но это должно дать вам представление о том, как сделать магазин GUI =)

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...