Splitting the module into tables stops the script[CLOSED]

Hello! My problem is that when I do in the module

--Module
local PositionModule =	{}

PositionModule.BasicShop = {

	[1] = CFrame.new(28.9639988, 1.69099998, 9.8030014, 0, 0, -1, 0, 1, 0, 1, 0, 0),
	[2] = CFrame.new(28.9639988, 1.69099998, 14.7910004, 0, 0, -1, 0, 1, 0, 1, 0, 0),
	[3] = CFrame.new(28.9639988, 1.69099998, 19.661, 0, 0, -1, 0, 1, 0, 1, 0, 0)

}

return PositionModule

that is, it create a table within a table in it it just stops working a local script

--local script
local RS = game:WaitForChild("ReplicatedStorage")

local ButtonL = script.Parent.L
local ButtonR = script.Parent.R
local Curret = script.Parent.Curret
local ShopForNow = script.Parent.ShopPicked
local Player = game.Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera

local PosTable = require(RS.Modules.BasePose)

ButtonL.MouseButton1Click:Connect(function()
	if Curret.Value == 1 then
		Camera.CameraType = Enum.CameraType.Scriptable
		Curret.Value = math.max(1,#PosTable)
		Camera.CFrame = PosTable[ShopForNow.Value][Curret.Value]
	else
		Curret.Value -= 1 
		Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CFrame = PosTable[ShopForNow.Value][Curret.Value]
	end
end)
ButtonR.MouseButton1Click:Connect(function()
	if Curret.Value == math.max(1,#PosTable) then
		Camera.CameraType = Enum.CameraType.Scriptable
		Curret.Value = 1
		Camera.CFrame = PosTable[ShopForNow.Value][Curret.Value]
	else
		Curret.Value += 1 
		Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CFrame = PosTable[ShopForNow.Value][Curret.Value]
	end
end)


(sorry for the watermark, the video has become a little more than 10mb)

Where is the problem?

Did it work before you moved that to a module script?

1 Like

When Module was like that, everything worked

local PositionModule =	{


	[1] = CFrame.new(28.9639988, 1.69099998, 9.8030014, 0, 0, -1, 0, 1, 0, 1, 0, 0),
	[2] = CFrame.new(28.9639988, 1.69099998, 14.7910004, 0, 0, -1, 0, 1, 0, 1, 0, 0),
	[3] = CFrame.new(28.9639988, 1.69099998, 19.661, 0, 0, -1, 0, 1, 0, 1, 0, 0)

} 

return PositionModule

Those two things aren’t identical. In the working one, you can access the first cframe like:

local positionModule = require(PositionModule)
local cframe1 = positionModule[1]

In the non-working one, you’d need to do

local cframe1 = positionModule.BasicShop[1]
1 Like

i.e. I won’t be able to make this script universal by using PosTable[ShopForNow.Value][Curret.Value]?

You can do that if ShopForNow.Value is a valid index in PosTable, such as the string “BasicShop”. Im not sure why it wouldn’t work as it is, are there any errors?

1 Like

image

i just reorganized it

local RS = game:WaitForChild("ReplicatedStorage")

local ButtonL = script.Parent.L
local ButtonR = script.Parent.R
local Curret = script.Parent.Curret
local ShopForNow = script.Parent.ShopPicked
local Player = game.Players.LocalPlayer
local Camera = game.Workspace.CurrentCamera

local PosTable = require(RS.Modules.Shops[ShopForNow.Value])

ButtonL.MouseButton1Click:Connect(function()
	if Curret.Value == 1 then
		Camera.CameraType = Enum.CameraType.Scriptable
		Curret.Value = math.max(1,#PosTable)
		Camera.CFrame = PosTable[Curret.Value]
	else
		Curret.Value -= 1 
		Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CFrame = PosTable[Curret.Value]
	end
end)
ButtonR.MouseButton1Click:Connect(function()
	if Curret.Value == math.max(1,#PosTable) then
		Camera.CameraType = Enum.CameraType.Scriptable
		Curret.Value = 1
		Camera.CFrame = PosTable[Curret.Value]
	else
		Curret.Value += 1 
		Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CFrame = PosTable[Curret.Value]
	end
end)

Let you have a mark as a solution

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