Please read this, I know its long but i'm pretty desperate. Also i'm a beginner so understand my methods may not be the smartest way of solving my problems.
I am so confused... I need help with this shop script I built, which activates when a player clicks on a mannequin's shirt. When clicked, the script will bring up a prompt asking you to store it into cart. If you press yes, the script will copy the shirtID from the mannequin and paste it to a virtual 'card' which then takes that ID, gets the information from the product, then displays information about the shirt(name, price, thumbnail) within text labels in its 'card.' This card will go inside a virtual cart where players can store their cards before wanting to buy, try on, or delete the shirt in the card. (buying, trying on, and deleting items from the cart have not been scripted yet)
Two problems are showing up.
One thing. When you press yes the first time on a shirt, everything works normally. But if you press yes on that same shirt or another shirt, duplicates of each shirt added to cart appear. (ex. if you click yes on a shirt the first time, one shows up in cart, but if you click yes on that same shirt or another shirt, multiple duplicates of both selected shirts show up in cart.) What I want is simply for 1 shirt to appear after clicking on it, then another shirt after clicking on that. I don't know what I did wrong but hopefully you might.
Second thing. When I press play in my place, outside of RobloxStudio, none of the scripts having to do with clicking in a GUI work? (My places were updated immediately after adding in these scripts.) I can't click on a shirt to bring up a prompt, or open up the cart? I am sure that the lack of local scripts may have something to do with the problem, however I do not understand how the script could work in studio and not in game? Even a simple script that opens and shuts the cart doesn't work? What do I do?
none of these are local scripts, however besides the card duplication messup, they all work great in studio, so...?
and if you were wondering why i made something initially simple complicated, yes i want it to be this complicated because i want to make something original. I know there are easier clothes buying scripts i can make but i wanna make this one more ambitious.
script.Parent.ClickDetector.MouseClick:connect(function() local player = game.Players.LocalPlayer local cart = player.PlayerGui.Cart.CartOverlay.CartBox.ItemSelection player.PlayerGui.AddToCartPrompt.Prompt.Visible = true function FindShirtID() if true then return (string.sub(script.Parent.Parent.Body.Shirt.ShirtTemplate, 14)) end end player.PlayerGui.AddToCartPrompt.Prompt.YesButton.MouseButton1Click:connect(function() print("Yes Button Clicked") player.PlayerGui.AddToCartPrompt.Prompt.Visible = false game.ServerStorage.ItemBox:Clone().Parent = cart cart.ItemBox.ItemID.Value = FindShirtID() cart.ItemBox.Name = cart.ItemBox.ClothesName.Text cart.Parent.Visible = true print("Card Successfully Duplicated: Shirt 1") -- there are different types of these scripts, with Shirt 1, Shirt 2, and Shirt 3 end) player.PlayerGui.AddToCartPrompt.Prompt.NoButton.MouseButton1Click:connect(function() player.PlayerGui.AddToCartPrompt.Prompt.Visible = false end) end)
script.Parent.MouseButton1Click:connect(function() local openevent = script.Parent.Parent.Parent.Parent.Cart.CartOverlay.CartBox if openevent.Visible == true then openevent.Visible = false elseif openevent.Visible == false then openevent.Visible = true end end)
function GetItemInfo() wait(.1) local Asset = game:GetService("MarketplaceService"):GetProductInfo(script.Parent.ItemID.Value) local item = script.Parent item.ClothesName.Text = Asset.Name item.Price.Text = "Price: "..tostring(Asset.PriceInRobux).."R$" item.ClothesImage.Image = Asset.IconImageAssetId item.MadeBy.Text = Asset.Creator.Name print("Gathered Item Info for Card: "..Asset.Name) end GetItemInfo()
What shows up on Output after clicking 'Yes' on 3 different shirts-
Yes Button Clicked
Card Successfully Duplicated: Shirt 1
Gathered Item Info for Card: ReXx Camo Sweatshirt
Card Successfully Duplicated: Shirt 2
Yes Button Clicked
Card Successfully Duplicated: Shirt 1
Gathered Item Info for Card: ReXx Camo Sweatshirt
Gathered Item Info for Card: ReXx Red Plaid Sweatshirt
Card Successfully Duplicated: Shirt 3
Yes Button Clicked
Card Successfully Duplicated: Shirt 2
Yes Button Clicked
Card Successfully Duplicated: Shirt 1
Gathered Item Info for Card: ReXx Red Plaid Sweatshirt
Gathered Item Info for Card: ReXx Camo Sweatshirt
Gathered Item Info for Card: Black Smoke Sweatshirt