I’m trying to make a shop GUI but I ran into a problem, when someone clicks the item they want to buy, how do I get the purchase button to know what item to give them?
1 Like
You can store string values inside the button then search for the item name in your item storage based off the string value
local itemStorage = game.ReplicatedStorage--change this to wherever you're storing items
button.Activated:Connect(function()
local item = itemStorage:FindFirstChild(button.StringValue.Value)
if item then--if the item exists then the script will continue
--then you could clone item and give it to the player here.
end
end)
if this doesn't make sense / you have any questions let me know!
I did more research and figured out I can send the data using a client to server Remote Event
https://devforum.roblox.com/t/how-to-send-numbervalue-to-server-with-remote-eventfunction/764479