[ SOLVED ] Argument 1 missing or nil

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    For the remote function to pass information to the server without error

  2. What is the issue? Include screenshots / videos if possible!
    When pressing on the button the button name is meant to be sent through a remote function but the thing is that, when the button name has a space eg: “MP Formals” it does not pass through and gives me a error “Argument 1 missing or nil”, I went through multiple tests to see what the issue is and haven’t found anything. I put the string into a table, I split it and sent those pieces individually, but it always ends up with “Argument 1 missing or nil” anytime the string has a space in it. The only string that works and actually processes is “CIC”. :InvokeServer() doesn’t have any arguments to pass through and my values don’t end up as nil so I really don’t understand

image
image
“CIC” will work and some of the others but most won’t
image

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried a lot of different things and still haven’t concluded the error

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- Local Script
for _, Button : TextButton in pairs(Outfits:GetChildren()) do
	if Button:IsA("TextButton") and KitEquipDebounce == false then
		Button.MouseButton1Click:Connect(function()
			print(_, Button)
			
			KitEquipDebounce = true
			
			OutfitType = { Button.Name , Button.Text }
			print(OutfitType)
			
			local RandomChance = math.random(1, 100)
			
			if RandomChance == 52 then
				EquipSound2:Play()
			else
				EquipSound1:Play()
			end
			
			task.wait(KitEquipCooldownTime)
			LockerEvent:InvokeServer(OutfitType)
			KitEquipDebounce = false
		end)
	end
end

-- Server Script
LockerEvent.OnServerInvoke = function(Player, ClothingFolder : any)
	local Character = Player.Character
	
	for _, Object in pairs(Character:GetChildren()) do
		if Object:IsA("Model") then
			if Object.Name ~= "ODM BLAH BLAH BLAH" then
				Object:Destroy()
			end
		end
	end
	
	print(Player, ClothingFolder)
	
	for _, ClothingModel in pairs(game.ServerStorage.LockerSystem.FullKits:FindFirstChild(ClothingFolder[1]):GetChildren()) do
		task.wait()
		local LimbAttribute = ClothingModel:GetAttribute('Clothing')
		
		local Clothing = ClothingModel:Clone()
		Clothing.Parent = Character
		
		if LimbAttribute ~= '2D' then --Make sure that the clothing is not 2d, you can not weld 2d clothing
			local LimbToAttachTo = Character:FindFirstChild(LimbAttribute) --check which limb its for
			Clothing.Middle.CFrame = LimbToAttachTo.CFrame --⭐
			local Weld = Instance.new('ManualWeld', ClothingModel:FindFirstChild('Middle')) --find middle part of model
			Weld.Part0 = LimbToAttachTo --attach main part of weld to limb
			Weld.Part1 = Weld.Parent --attach secondary to middle of clothingModel
			Weld.C0 = CFrame.new(0,0,0)
		end
	end
	
	game.ReplicatedStorage.RefreshView:FireClient(Player)
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

3 Likes

So CIC works, both FIS and IIS doesn’t work but also doesnt produce any error, and the rest produce the error am I right?

3 Likes

CIC is the one thing that works due to it not having any spaces in its name, the rest that do have multiple words/spaces in the name don’t work. (Sorry for not changing the image, The buttons didn’t fit the folder name so I had to change them)

I have no idea what caused such problem, but could it be because you’re parenting the ManualWeld to the part ‘Middle’ inside ‘ClothingModel’ instead of the part ‘Middle’ inside ‘Clothing’?

1 Like

Which line causes the error? Telling us can help narrow it down.

1 Like

When I am invoking the server, When I invoke the server I always get the warning “Argument 1 missing or nil”. I checked plenty of times around the script and have never found where the variable ends up nil.

1 Like

It will say where in the server-script the error came from in the red text, but the blue text (the “stacktrace”) will reference the :InvokeServer call.

ServerScriptService.ServerScript:2: Argument 1 missing or nil  -  Client - LocalScript:3
Stack Begin  -  Studio
Script 'Players.Judgy_Oreo.PlayerScripts.LocalScript', Line 3  -  Studio - LocalScript:3
Stack End

The red text, in this case, is ServerScriptService.ServerScript:2 Argument 1 missing or nil, but clicking it will take you to the script in the blue text, Script 'Players.Judgy_Oreo.PlayerScripts.LocalScript', which only calls :InvokeServer:

When the actual issue is in the server-script:

, as shown in the error:

(Note: errors like this with RemoteFunctions actually give 2 errors, one for the server and one for the local script. If you scroll up, you can find the error for the server, which, when clicked, takes you to the part of the server-script that caused the error.)

1 Like


There is no issue on the server side, only client side

1 Like

Then why did you point out this line? The error can only come from the server code, if the error takes you to an :InvokeServer function.

1 Like

Sorry, I never knew that the remote function will throw the error back to client. I ended up finding the issue and it was caused from attributes which I forgot to check.

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