I am trying to create a shop from tools in a folder in ReplicatedStorage in each tool there are settings with a DamageMultiplier, its Price, and an Image I want to duplicate all of these into the frame so far I have the name down how can I get the rest
Ive been trying different ways and I cant seem to understand how I can do this. I am assuming we would use a for loop but if there are any thoughts let me know
I have been looking for similar issues on the Developer Forum and it did help clear up some things but I still cant seem to figure this out.
local RS = game:GetService("ReplicatedStorage")
local SG = game:GetService("StarterGui")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Template = script.Parent.Template
local items = RS.MiningTools:GetChildren()
local dupe = function(name)
local clone = Template:Clone();
clone.Parent = script.Parent
clone.Title.Text = name
clone.Visible = true
--clone.Price.Text = Price
--clone.Image.ImageID = ""
end
for _, i in ipairs(items) do
dupe(i.Name)
end;
If anyone has any thoughts please let me know because anything will help thank you.
I have the shop set up as a pop up with a touch part and I want all the items I have in a folder in replicated storage to be on a gui template in the shop
i mean you could just make a new frame for that tool in the for loop, and there just make a new frame with the name or something? i would guess it would be kind of like this:
for i, v in pairs(items) do
local name = v.Name
local newframe = Instance.new("Frame")
local newtext = Instance.new("text")
newtext.Text = name
-- make the offsets and whatever else you want
newtext.Parent = newframe
newframe.Parent = --put reference to the gui here
end
Wouldn’t it be inefficient to do this because of lag and creating nre frames from script for every player?
I want to take everything in the MiningTools folder which contains the tool itslef along with the tool settings and make a GUI out of a gui template
I have already gotten the names to go onto the frame my question is how can I do this and add the prices and image into the frame like I did with the names
local RS = game:GetService("ReplicatedStorage")
local SG = game:GetService("StarterGui")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Template = script.Parent.Frames.Template
local items = RS.MiningTools:GetChildren()
local duplication = function(name)
local clone = Template:Clone();
clone.Parent = script.Parent
clone.Title.Text = name
clone.Visible = true
--local price = --??? How can I name this variable
--clone.Price.Text = price
end
local frames = SG.MineGUI.Shop.ScrollingFrame.Frames:GetChildren()
for eachitem, selectedItem in items do
local price = selectedItem.Settings.Price.Value
duplication(selectedItem.Name)
print(selectedItem.Name, price)
end;
If I can figure thia part out I might be able to work it out
--local price = --??? How can I name this variable
--clone.Price.Text = price
why are you doing duplication(name) if you could just do duplication(tool) and then there just use the tool instance with all the values and stuff?? your logic is a tad bit weird ill tell you that.