Why isn't my module variables updating?

I have a script that calls on a module that has textlable data for a GUI, problem is the data being received from the module isn’t updating when I change which table in the module is being called upon, any idea why?

LocalScript
--Module Variables--
local module = require (game.ReplicatedStorage.Modules.GuiWeponData)
local page = 1
local totalpage = 5
local item = module[page]

--GUI Elements--
local ItemName = script.Parent.itemname
local ItemDesc = script.Parent.itemdesc
local AttackStat = script.Parent.attackstat
local TimeStat = script.Parent.timestat
local SpecialStat = script.Parent.specialstat
local ItemRarity = script.Parent.itemrarity
local Next = script.Parent.Next


--Main Script--

Next.MouseButton1Click:Connect(function()
	if page >=1 and page < totalpage then
		page = page + 1
		print(page)
	elseif page < 1 then
		page = 1
	else if page > totalpage then
			page = totalpage
		end
	end 
end)

while true do
	wait(0.1)
	ItemName.Text = item.Name
	ItemDesc.Text = item.Description
	AttackStat.Text = item.AttackTime
	TimeStat.Text = item.AttackTime
	ItemRarity.Text = item.Rarity
	if item.Special == "N/A" then
		SpecialStat.Visible = false
	else
		SpecialStat.Text = item.Special
	end
end
Module
local loot = {
	[1] = {

		Name = "Baseball Bat";
		Description = "Useful for playing sports, and bashing in heads.";
		Damage = 10;
		AttackTime = .9;
		Special = "N/A";
		Rarity = "Common"
		
	};

	[2] = {
		
		Name = "Brass Nuckles";
		Description = "These bad-boys have a devistating punch.";
		Damage = 13;
		AttackTime = .5;
		Special = "N/A";
		Rarity = "Common"
	};

	[3] = {
		
		Name = "Busted Pistol";
		Description = "An old rusty pistol.";
		Damage = 20;
		AttackTime = .3;
		Special = "25% chance of a jam while firing";
		Rarity = "Common"
	};

	[4] = {
		
		Name = "Stolen Police Baton";
		Description = "Commonly used by police officers, unless stolen.";
		Damage = 15;
		AttackTime = .7;
		Special = "N/A";
		Rarity = "Common"
	};
	[5] = {
		
		Name = "Mauser-C96";
		Description = "A fully-automatic pistol.";
		Damage = 22;
		AttackTime = .05;
		Special = "Fire of Glory: All damage increased by 10% for 7 secconds";
		Rarity = "Common"
	}

}

return loot
1 Like

You aren’t assigning a new value the item variable.

I was trying to make it so that the item variable would change based on which page I was on (the page variable, what would you recommend instead?

You have to update the item variable to module[page] every time.