'Attempt to call a nil value'

Hi, my script isnt working for a simple purchasing script. It doesn’t get past the require, and output spits out the error attempt to call a nil value.
The Server-side script attached to a ProxPrompt:

	require(game.ReplicatedStorage.Modules.RequestPurchase).RequestPurchase(player, "ClassicSword")

the module:

local RequestPurchase = {}
local PurchaseModule = require(script.PurchaseModule)
local RS = script.Parent.Parent
local Module3D = require(script.Parent.Module3D)
local SwordRepo = script.Parent.Parent.Items.Swords

function RequestPurchase.RequestPurchase(player, purchaseItem)
	PurchasePrompt = player.PlayerGui.Other.PurchasePrompt
	M3DFrame = PurchasePrompt.M3DFrame
	script.CurrentPurchaseItem = tostring(purchaseItem)
	if tostring(purchaseItem) == "ClassicSword" then
		if player:WaitForChild("SwordData")
			:WaitForChild("ClassicSword") then
		PurchasePrompt["Confirmation?"].Text = 'Are you sure you want to purchase "Original Sword?"'
		Module3D:Attach3D(M3DFrame, SwordRepo.ClassicSword)
			PurchasePrompt.Visible = true

return RequestPurchase

Have you checked to make sure the module loads correctly outside of that script, and also if you are just housing that requestpurchase method within that module you can just do return function(player,…)

This will give you a good place to start.

Also is the nil value error outputted when the method is called, you should check it with a print statement before any following code executes.

how do i check if the module loads correctly outside of that script?

Put a print before your function in the module.