Neplioz
(Neplioz)
February 21, 2022, 7:34pm
#1
What do you want to achieve?
Hello, so i want to make a shop with a module script example in the module script :
[“Test Item”] {
price = 10
}
And it adds automatically to the gui with a UILayout
What is the issue?
I can’t manage to do it
What solutions have you tried so far?
I tried myself and looked on forums
1 Like
Make a module as simple as that
local ShopItems = {
["Item1"] = { Name = "Sword", Price = 5},
["Item2"] = { Name = "Gun", Price = 10},
}
Inside the gui, loop through this table and create a frame/whatever and insert the data in e.g
for index, shopItem in pairs(ShopItems) do
local newItem = template:Clone()
newItem.ItemName.Text = shopItem.Name
newItem.Price.Text = shopItem.Price
newItem.Visible = true
newItem.Parent = itemScrollingFrame
end
1 Like
Neplioz
(Neplioz)
February 21, 2022, 7:44pm
#3
Thank you, and how can i do with the buy button ? (Im sorry im new to modules scripts)
That’s fine dw,
Inside the template frame, you could also add the buy button inside
for index, shopItem in pairs(ShopItems) do
local newItem = template:Clone()
newItem.ItemName.Text = shopItem.Name
newItem.Price.Text = shopItem.Price
newItem.BuyButton.MouseButton1Down:Connect(function()
ShopEvent:FireServer("BuyItem", shopItem.Name)
end)
newItem.Visible = true
newItem.Parent = itemScrollingFrame
end
1 Like
Neplioz
(Neplioz)
February 21, 2022, 7:48pm
#5
Okay, thank you for answering ! It helped my alot!
1 Like
No problem, good luck! [limit]
1 Like
What do you do if you have a leaderstats on a diffrent script and want to make a purchase/shopHandler on a diffrent script. How could you get gold?