ModuleScript and localscript cant access same intvalue

I have a localscript that changes a intvalue whenever a button is pressed, up for +1 down for -1.

local Back = script.Parent.Back
local Next = script.Parent.Next
local IDUpdater = script.Parent.Parent.IDUpdater
local PageNum = IDUpdater.Page.Value


Back.MouseButton1Down:Connect(function()
	if PageNum == 1 then
		
	else
		PageNum = PageNum - 1
		require(IDUpdater).ID()
		print("PageNumber is " .. PageNum)
	end
end)

Next.MouseButton1Down:Connect(function()
	if PageNum == 3 then

	else
		PageNum = PageNum + 1
		require(IDUpdater).ID()
		print("PageNumber is " .. PageNum)
	end
end)

And I have a module script that uses that intvalue to change something correspondly

local GetID = {}

function GetID.ID()
	local val
	local PageNum = script.Page.Value
	
	local IDtable = {
		
		ID1 = "http://www.roblox.com/asset/?id=15725727683"
				
	}
	
	for _, ID in pairs(script.Parent:GetDescendants()) do
		if ID.ClassName == "IntValue" then
			if ID.Name == "ID" .. tostring(PageNum) then
				
				if ID.Value == 1 then
					
					ID.Parent.Image = IDtable.ID1
					
					print("PageNumber is " .. PageNum)
				else 
					ID.Parent.Image = ""
				end
				
			end
			
		end
	end
end

return GetID

The issue is that, the intvalue does not change for the module script

L is for localscript and M is for module btw.

Nothing is changing the page number back to 1, also the page number value is parented to the module script if that helps

You’re setting the PageNum variable to the current value.
Which means you’re no longer changing the Pagenumber and instead just a number

Wow, thank you so much, I never even saw that

No it’s not?
IntValue | Documentation - Roblox Creator Hub.

Yeah, what do you mean by this? Are there alternatives I haven’t heard about?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.