ServerScriptService.Siekiery.Scinanie:383: invalid argument #3 (string expected, got nil)

so im trying to fix some bugs in my axe system in my tree game but for some reason i keep getting this error:

ServerScriptService.Siekiery.Scinanie:383: invalid argument #3 (string expected, got nil)
it appears here

image

that is a module script fired from this script:

image
i dont know why but in when i fire other functions from this module with plr.Name they work?

1 Like

I looked at your script and problems, please be more specific.

Since it says (string expected, got nil) means that there nothing in that line (or the plr has not been found)

yeah but it worked in the previous module script function calls which means it could be roblox fault maybe idk

It simply means Player has not been found. To make sure this is the case, use print(PlayerName) and you’ll be returned nil.

yeah i did that its nil ima put the plr variable inside the function then

oh yea i forgot there is no plr variable


this is the plr variable

You do realize it says inavlid argument #3 which means the “badyl” variable is the undefined one, not the plr.Name.

this is badyl variable. its something with player coz it says nil, and badyl worked before so i dont think its badyl

also it is a local script if ur wondering

Just in case, run the script and add

print(ru)

somewhere in there. If it prints nil, we know that’s the problem.

okay let me do that real quick.

image
first one is wood type, second one is the badyl and third one is player name

1 Like

Are you using “height” as the plr.Name in this case? If so, that isn’t a string and may be the reason it’s returning nil.

nope, i define player name in the next script

local remote = game.ReplicatedStorage.Remotes.NoweSciecie
local RR3 = require(game.ServerScriptService.RotatedRegion3)
local module = require(game.ServerScriptService.Siekiery.Scinanie)

remote.OnServerEvent:Connect(function(plr,pozycja,segment,badyl,glowa)
	if tostring(segment) == "Drewno" or tostring(segment) == "Sciecie" then
		local badylmodule = require(game.ServerScriptService.Siekiery.RodzajeUchwytow:FindFirstChild(badyl))
		local minDystansOdDrzewa = badylmodule.dystans
		local cooldown
		local treeClass
		local char = plr.Character
		if tostring(segment) == "Drewno" then
			treeClass = segment.Parent:FindFirstChild("RodzajDrzewa")
		elseif tostring(segment) == "Sciecie" then
			treeClass = segment.Parent.Parent:FindFirstChild("RodzajDrzewa")
		end
		if table.find(badylmodule.specialtreeclasses,treeClass.Value) then
			cooldown = badylmodule.specialtreeopoznienie
		else
			cooldown = badylmodule.opoznienie
		end
		local cv = plr:FindFirstChild("Cooldown")
		if cv.Value == false then
			cv.Value = true
			if tostring(segment) == "Drewno" then
				local plrx = char.HumanoidRootPart.Position.X
				local plry = char.HumanoidRootPart.Position.Y
				local plrz = char.HumanoidRootPart.Position.Z
				local objx = segment.Position.X
				local objy = segment.Position.Y
				local objz = segment.Position.Z
				local calcx = plrx - objx
				local calcy = plry - objy
				local calcz = plrz - objz
				local BeamFirst = calcx^2 + calcy^2 + calcz^2
				local BeamTwo = math.sqrt(BeamFirst)
				if BeamTwo <= minDystansOdDrzewa then
					local przesuniecie = Vector3.new(0,segment.CFrame:pointToObjectSpace(pozycja).Y,0)
					local region = RR3.new(segment.CFrame * CFrame.new(przesuniecie),Vector3.new(segment.Size.X+0.02,0.5,segment.Size.Z+0.02))
					local parts = region:FindPartsInRegion3()
					local sciecie
					for i,v in pairs(parts) do
						if v.Name == "Sciecie" then
							sciecie = v
						end
					end
					if sciecie == nil then
						module.noweSciecie(pozycja,segment,badyl,glowa,plr.Name)
					else
						module.powiekszSciecie(sciecie,segment,badyl,glowa,plr.Name)
					end
				end
			elseif tostring(segment) == "Sciecie" then
				local plrx = char.HumanoidRootPart.Position.X
				local plry = char.HumanoidRootPart.Position.Y
				local plrz = char.HumanoidRootPart.Position.Z
				local objx = segment.Position.X
				local objy = segment.Position.Y
				local objz = segment.Position.Z
				local calcx = plrx - objx
				local calcy = plry - objy
				local calcz = plrz - objz
				local BeamFirst = calcx^2 + calcy^2 + calcz^2
				local BeamTwo = math.sqrt(BeamFirst)
				if BeamTwo <= minDystansOdDrzewa then			
					module.powiekszSciecie(segment,segment.Parent,badyl,glowa,plr.Name)
				end
			end
			wait(cooldown)
			cv.Value = false
		end
	end
end)

I’m not sure why this is nil. Maybe try getting the player’s Character’s name (should be the same anyway)

ya it prob will but ima try anyways

nope i am still getting the same error