I am having trouble with a GUI that allows a player to choose their logo and color which would direct them to buy the shirt with those options. However, I am stuck at this process. How would you do it? Here's how they are placed:
ShopGui > Shirts (Frame) > Design1, Design2, Textures(frame) > Texture1, Texture2, Open/Close (button)
Here's the localscript that will be used inside Design1 and Design 2:
local design = script.Parent local sframe = script.Parent.Parent local gui = sframe.Parent design.MouseButton1Down:connect(function() if design then gui.Textures.Visible = true sframe.Visible = false end end)
Here's the localscript that will be used inside Texture1 and Texture2:
local texture1 = script.Parent local player = game.Players.LocalPlayer local marketplace = game:GetService("MarketplaceService") local shirt = -- I know there's more than just one shirt but idk what to do in this case texture1.MouseButton1Down:connect(function() marketplace:PromptPurchase(player,shirt) end)
In case you need the open/close localscript:
local button = script.Parent local display1 = button.Parent.Shirts local display2 = button.Parent.Textures button.MouseButton1Down:connect(function() if display1.Visible and display2.Visible then display1.Visible = false display2.Visible = false else display1.Visible = true display2.Visible = false end end)
First, you do not need to have the shirt variable set right away (you can simple put local shirt
without the equal sign), you can have the MouseButton1Down event handler return if the shirt is not set: if shirt == nil then return end
A good solution could be to have a table that links colors and logos to their shirt:
local shirt = { ['1,0,0'] = { logo1 = "red logo1 asset", logo2 = "red logo2 asset" }, ['0,1,0'] = { logo1 = "green logo1 asset", logo2 = "green logo2 asset" } } local function colorToString(color) return tostring(color.r) .. "," .. tostring(color.g) .. "," .. tostring(color.b) end local function getTemplateByColorAndLogo(color, logoName) return shirt[colorToString(color)][logoName] end
Next you will need some buttons to set the color and logo name. How you do this depends on your design.You can have functions handling which button is pressed and then have it set a variable for the color and logo (then you could have the MouseButton1Down event handler get the shirt using those variables if they are set).