So basically I’m making a Homestore and I wanted to create a GUI so that people could TRY and BUY my clothing. This is how I wanted it to work: The player joins the game and has the UI closed but when they click on a mannequin the GUI appears and they get the option to purchase, try it and close the gui. I have not found any type of tutorial to help me out with this so if anyone could help please.
In button mannequin you should add a LocalScript and store your the second gui (this gui should include option to purchase button, try on button and close button) into ServerStorage.
The code in mannequin should look like this:
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Down:Connect(function()
local SecondGui = game.ServerStorage:FindFirstChild("SecondGuiNameHere")
local clone = SecondGui:Clone()
clone.Parent = player.PlayerGui
end)
Of course you will have to tell me if you don’t know how to code anything else or more.
I can tell you from the start that try feature is more complicated than buy feature. Before we do anything I’d strongly recommend that you add an IntValue in each clothes gui so we will know which clothes ID player is looking at. You will have to create an palce where player’s character is going to stand so they can see themselves in this clothes. I would change character’s ShirtTempalte. The code should look like this in LocalScript of course.
local player = game.Players.LocalPlayer
local YourLocation = Vector3.new(0,0,0) --Set this to your doll's location
script.Parent.MouseButton1Down:Connect(function()
local ShirtID = script.Parent.Parent:FindFirstChild("ShirtIDIntValue").Value
local PantsID = script.Parent.Parent:FindFirstChild("PantsIDIntValue").Value
local Doll = workspace:FindFirstChild(player.Name):Clone()
Doll.Parent = workspace:FindFirstChild("DataDollFolder") -- create your folder in workspace
Doll.Name = player.Name.."Doll"
Doll.CFrame = CFrame.new(YourLocation)
if Doll:FindFirstChild("Shirt") ~= nil then
Doll:FindFirstChild("Shirt").ShirtTemplate = ShirtID
end
if Doll:FindFirstChild("Pants") ~= nil then
Doll:FindFirstChild("Pants").PantsTemplate = PantsID
end
end)
Now let’s move to Buy LocalScript button. First of all we should check if player has enough money to buy this clothes and if so it should be added into their inventory or boolvalue turned to true it depends how your datastore works. Now let’s get started.
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Down:Connect(funciton()
local PlayerCash = player:FindFirstChild("leaderstats").Cash.Value
local ClothName = script.Parent.Parent:FindFirstChild("SelectedCloth").Value
local ClothCost = script.Parent.Parent:FindFirstChild("ClothValue").Value
if PlayerCash >= ClothCost then
local clone = game.ServerStorage:FindFirstChild(ClothName).Clone()
clone.Parent = player:FindFirstChild("Inventory")
else
end
end)
Now the last thing is out close button which is going to look like this:
local player = game.Player.LocalPlayer
script.Parent.MouseButton1Down:Connect(function()
player.PlayerGui:FindFirstChild("SecondGuiNameHere"):Destroy() --
if workspace:FindFirstChild("DataDollFolder")[player.Name.."Doll"] ~= nil then
workspace:FindFirstChild("DataDollFolder")[player.Name.."Doll"]:Destroy()
end
end)
I think you might have problems with Doll rotation but maybe you could check it out on the web.
I hope this helps you out.