Attempted to call require with invalid argument(s), but there is an argument?

so im trying to make an axe script for my tree game. for the axe i need mouse target, position of mouse on the target, type of axe head and type of axe handle.
so the script works like this:
LocalScript in the Axe calls a FireServer() → the FireServer() fires a Module Function → the module function creates a cut

i mean its supposed to work like that but something ofc is not working.

error i am getting: Attempted to call require with invalid argument(s)
on this line
local badylmodule = require(game.ServerScriptService.Siekiery.RodzajeUchwytow:FindFirstChild(badyl))

so here is the local script that calls the server event:

local tool = script.Parent

local remote = game.ReplicatedStorage.Remotes.NoweSciecie

local plr = game.Players.LocalPlayer

local mouse = plr:GetMouse()

tool.Activated:Connect(function()

local ru = tool.RodzajUchwytu.Value

local rg = tool.RodzajGlowy.Value

remote:FireServer(plr,mouse.Hit.p,mouse.Target,ru,rg)

end)

here is the server event it is calling:
local remote = game.ReplicatedStorage.Remotes.NoweSciecie

remote.OnServerEvent:Connect(function(plr,pozycja,segment,badyl,glowa)

local module = require(game.ServerScriptService.Siekiery.Scinanie)

module.noweSciecie(pozycja,segment,badyl,glowa)

end)

and here is the module:
local module = {}

module.noweSciecie = function(pozycja,segment,badyl,glowa)
	local badylmodule = require(game.ServerScriptService.Siekiery.RodzajeUchwytow:FindFirstChild(badyl))
	local glowamodule = require(game.ServerScriptService.Siekiery.RodzajeGlow:FindFirstChild(glowa))
	local treemodule = require(game.ServerScriptService.Drzewa.RodzajeDrzew:FindFirstChild(segment.Parent.RodzajDrzewa.Value))
	local sciecie = Instance.new("Part",segment)
	local twardosc = treemodule.twardosc
	local silasiekiery
	local tablezespecialdrzewami = {}
	for i,v in pairs(glowamodule.specialtreeclasses) do
		table.insert(tablezespecialdrzewami,v)
	end
	if table.find(tablezespecialdrzewami,segment.Parent.RodzajDrzewa.Value) then
		silasiekiery = glowamodule.specialtreemoc
	else
		silasiekiery = glowamodule.moc
	end
	local length = twardosc/250 * silasiekiery
	sciecie.Size = Vector3.new(segment.Size.X + 0.02,0.15,length)
	local nwmjaknazwac = segment.Size.Z-0.02 / 2
	local przesuniecie = Vector3.new(0,0,nwmjaknazwac)
	sciecie.CFrame = segment.CFrame * CFrame.new(przesuniecie)
	sciecie.Anchored = true
	sciecie.Color = Color3.fromRGB(255,255,255)
	sciecie.Reflectance = 1 sciecie.CanCollide = false
	local maxlength = segment.Size.X + 0.02
end

return module

i know the module doesnt make sense and its not gonna work anyways but i atleast want it to work (i mean fire and dont give any errors). im gonna take care of the rest later

1 Like

Probably that it couldn’t find the ModuleScript.

Have you tried printing the path to check it isn’t nil?

print(game.ServerScriptService.Siekiery.RodzajeUchwytow:FindFirstChild(badyl))

Double check it is a ModuleScript, not a regular script, and that printing the path as shown above directly above your require line prints what you expect it to.

ima try that
also i have played your rubiks game rn and got a world record, nice game

it prints nil for some reason. could it be because of the local script that fires the fireserver with all the variables?

If it prints nil, it means the FindFirstChild bit didn’t find it. It might be worth double checking the name, checking that it’s in the RodzajeUchwytow folder when you actually run the game in studio.