Le code suivant peut être utilisé pour donner au joueur la boutique IUG:
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)
Notez que « ShopPart » devrait être une grande partie qui couvre toute la zone du magasin (de préférence invisible)
Ensuite, vous devez également créer une boutique gui.
Dans la boutique vous devez faire IUG TextButtons (ou des boutons d'image) que chaque contient le script suivant:
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)
Le code n'a pas été testé, il peut contenir des erreurs. Et vous pourriez avoir besoin de changer plus de choses que mentionné. Mais il devrait vous donner une idée sur la façon de rendre le shop gui =)
Nous ne sommes pas ici pour écrire votre code pour vous. Peut-être que si vous réduisiez la question à un domaine spécifique avec lequel vous avez des problèmes, quelqu'un serait en mesure de trouver une solution. –