Getting all vars inside a modulescript for a pairs() function

i just have a simple question, how do i properly get every variable from a modulescript so i get every variable’s name to copypaste every name to the “shopgui”
it somewhat works, but it only does the first value, i want it to do every value from the modulescript (sorry if this is so hard to read)

ModuleScript

local stts = {
	["GLOCK17"] = {
		Name = "GLOCK17",
		Damage = 12,
		HeadDamage = 30,
		Cost = 600,
		Ammo = 18
	};
	["AK47"] = {
		Name = "AK47",
		Damage = 15,
		HeadDamage = 50,
		Cost = 2500,
		Ammo = 30
	};
	["M4 CARBINE"] = {
		Name = "M4A1",
		Damage = 15,
		HeadDamage = 45,
		Cost = 1500,
		Ammo = 40
	};
	["XM1014"] = {
		Name = "XM1014",
		Damage = "DEPENDS",
		HeadDamage = "DEPENDS",
		Cost = 1000,
		Ammo = 8
	};
	["SVD"] = {
		Name = "SVD",
		Damage = 70,
		HeadDamage = 120,
		Cost = 1000,
		Ammo = 8
	};
}


return stts

the localscript

local event = game:GetService("ReplicatedStorage"):WaitForChild("EventsNotRelatedToCombat"):WaitForChild("UIShop")
local mod = require(workspace.tempmobilepurchasegui.Stats)
local ui = game:GetService("ReplicatedStorage"):WaitForChild("Name")



event.OnClientEvent:Connect(function()
	for i, v in pairs(mod) do
		local new = ui:Clone()
		ui.Parent = script.Parent.Main.d
		ui.Name = v.Name
		ui.Text = v.Name
	end
end)

i tried doing #mod, but it didn’t work

I think it’s more so you changing the properties of ui rather than the clone of it you made, new inside of the pairs loop

can you please reiterate what you’re saying?? i don’t quite get it

Basically, in your loop, you’re changign the properties of ui, ui.Name = v.Name, ui.Parent = script.Parent.Main.d

I think you meant to use new there rather than ui

event.OnClientEvent:Connect(function()
	for i, v in pairs(mod) do
		local new = ui:Clone()
		new.Parent = script.Parent.Main.d
		new.Name = v.Name
		new.Text = v.Name
	end
end)
1 Like

oh what why am i so stupid ill test it out in a later date! thanks!

1 Like