Argument 1 missing or nil with RemoteFunctions

I have a script that invokes a remote function from client to server, however it keeps saying argument 1 missing or nil, I am only passing 1 argument which is the client’s camera CFrame. I tried to find some solutions, and I tried printing the CFrame, but it didn’t say it was nil or blank.

This is my script:

LocalScript

local function Shoot(bindName: string, userInputState: Enum.UserInputState)
	if userInputState and userInputState ~= Enum.UserInputState.Begin then return end
	
	local registerHit = game:GetService('ReplicatedStorage'):WaitForChild("registerHit")
	
	local cframetopass = workspace.CurrentCamera.CFrame
	local hitData : hitdata = registerHit:InvokeServer(cframetopass)

the script looks ok are you sure the error in the output pointing to this line ?

Yeah, this is a function so it also mentioned the line that called the function and the line in the function that has the error.

do you mind showing the server code that listens to that InvokeServer?

Can I see the full error and stack trace?

10:56:04.536  Argument 1 missing or nil  -  Client - LocalScript:58
  10:56:04.536  Stack Begin  -  Studio
  10:56:04.536  Script 'Players.coolifysz.Backpack.RaycastGun.LocalScript', Line 58 - function Shoot  -  Studio - LocalScript:58
  10:56:04.536  Script 'Players.coolifysz.Backpack.RaycastGun.LocalScript', Line 105  -  Studio - LocalScript:105
  10:56:04.536  Stack End  -  Studio
1 Like

Removed script since it can be stolen

I changed the sever script around, I think it was something with the getAcessoriesForRaycast() function. Don’t know why though.

idk why but ihave feeling that you miss one of this parameters of ContextActionService:BindAction(string , function , boolean , Enum.KeyCode or Enum.UserInputType) ig

You don’t have to put the rest

you have to but the boolean after the function and at least one Enum or it’s going to throw an error
you can read more here

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