ModuleScript not loading on client

My issue is that the client replicator gets an error while loading, but if its exactly the same as the server why doesnt it work?

--Client Replicator

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local BridgeNet = require(ReplicatedStorage.Modules.BridgeNet2)
local Client = BridgeNet.ClientBridge("Ability")

local function FindAbility(AbilityName: string)

	local Module: any = false
	for _, v in ipairs( ReplicatedStorage.WeaponAbilities:GetDescendants() ) do
		if v:IsA('ModuleScript') and string.lower(v.Name) == string.lower(AbilityName) then
			print(v.Name)
			Module = require(v)
			break
		end
	end
	return Module

end

Client:Connect(function(content:any)
	warn(content)
	
	local WhichAbility = FindAbility(content[1])
	if WhichAbility == false then return end	
	WhichAbility.Client(content)
end)
--Server

local ReplicatedStorage=game:GetService("ReplicatedStorage")

local BridgeNet = require(ReplicatedStorage.Modules.BridgeNet2)
local Server = BridgeNet.ServerBridge("Ability")

local function FindAbility(AbilityName: string)

	local Module: any = false
	for _, v in ipairs( ReplicatedStorage.WeaponAbilities:GetDescendants() ) do
		if v:IsA('ModuleScript') and string.lower(v.Name) == string.lower(AbilityName) then
			Module = require(v)
			break
		end
	end
	return Module

end

Server:Connect(function(Player: Player, content: any)

	local Sending: list = {Player, content}

	--warn(content)
	local WhichAbility = FindAbility(content[1])
	if WhichAbility == false then return end	

	WhichAbility.Server(Sending)

end)
1 Like

that error usually pops up if there’s something wrong on the module script, you should go and see if there are any errors there.

2 Likes

But the issue is everything is working fine, it even does the damage but the client isnt loading the module

local module={}

function module.Server(Received: any)
	local player = Received[1]
	local whichsword = Received[2][2]
	local turn = Received[2][3]

	local gearName = whichsword.."Slash"
	local Character = player.Character
	local Tool = Character:FindFirstChild(whichsword)
	if Tool and not Character:GetAttribute("Attacking") and not GearDebounce.IsDebounced(player, gearName) then

		local SwordInfo = WeaponInfo:getweapon("Swords",whichsword)

		local cooldownTime = SwordInfo.Cooldown/Tool.Stats:FindFirstChild("Attack Speed").Value
		GearDebounce.SetDebounced(player, gearName, cooldownTime)
		Tool.Handle.SlashSound:Play()
		Character:SetAttribute("Attacking",true)
		local model=Instance.new("Model")
		model.Parent=workspace.Ignored
		local hitbox = ReplicatedStorage.WeaponAbilities.General.Swords.SlashBox:Clone()
		hitbox.Size = SwordInfo.Size
		local positionInFront = Character.HumanoidRootPart.Position + Character.HumanoidRootPart.CFrame.LookVector * 0
		local hitboxCFrame = CFrame.new(positionInFront, positionInFront + Character.HumanoidRootPart.CFrame.LookVector)
		hitbox.CFrame = Character.HumanoidRootPart.CFrame
		model.Name= player.Name.."'s "..whichsword.." Slash"..tick()
		hitbox.Parent=model

		if turn==2 then
			hitbox.Attachment.CFrame=CFrame.Angles(0,math.rad(90),math.rad(180))
		end

		Character:SetAttribute("CurrentHitbox",model.Name)
		model:ScaleTo(model:GetScale()*Tool.Stats:FindFirstChild("Attack Size").Value*player.Stats:FindFirstChild("Attack Size").Value)

		local weld = Instance.new("WeldConstraint")
		weld.Parent=hitbox
		weld.Part0=Character.HumanoidRootPart
		weld.Part1=hitbox

		local fireballoverlapparams = OverlapParams.new()
		fireballoverlapparams.FilterType = Enum.RaycastFilterType.Exclude
		fireballoverlapparams.FilterDescendantsInstances = {workspace.Ignored,Character}

		--Fires to all clients
		Server:Fire(BridgeNet.AllPlayers(),{"SwordSlash",{model.Name,SwordInfo.Color}})
		
		local alreadyhit={}

		local connection

		task.delay(0.1,function()
			connection:Disconnect()
			model:Destroy()
			Character:SetAttribute("Attacking",false)
		end)

		connection = RunService.Heartbeat:Connect(function(dt)
			local hitparts = game.Workspace:GetPartsInPart(hitbox,fireballoverlapparams)

			for i,v in hitparts do
				local hum = v.Parent:FindFirstChild("Humanoid")
				if hum and not table.find(alreadyhit,hum) and not Utilities.IsPlayer(player,Players:GetPlayerFromCharacter(hum.Parent)) then
					local drinstance = hum:FindFirstChild("DamageReduction")
					local dr

					if drinstance then
						dr=drinstance.Value
					else
						dr=0
					end
					Utilities.Tag(hum,player)
					hum:TakeDamage(Utilities.CalculateDamage(SwordInfo.Damage,dr,player,Tool.Stats.Power.Value))

					table.insert(alreadyhit,hum)
				end
			end
		end)
	end
end

function module.Client(Received: any)
	local hitbox=workspace.Ignored:FindFirstChild(Received[1])
	task.wait()
	hitbox.SlashBox.Attachment.Slash:Emit(2)
end

return module
1 Like

Any chance you’re not getting the table back soon enough to the client, I would expect it to complain about being nil but the module may not be passing on the error.

Not sure if your line count still matches what you posted here. Looking at the console your error is from line 12 which is checking if it’s a “ModuleScript” but if you’ve added a line in posting it would have been line 11 so the error would be when trying to iterate over the table.

If you try to GetDescendants() before FindAbility does it get the table and can you print it’s values?

local Descendants = ReplicatedStorage.WeaponAbilities:GetDescendants()

for _, Ability in ipairs(Descendants) do
    print(Ability.Name)
end

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