Error with InvokeServer

The problem is i get the error:

ServerScriptService.SimulateBulletScript:420: attempt to perform arithmetic (mul) on number and nil

And its on this line:

InflictTarget:InvokeServer("Gun", Cast.UserData.Tool, Cast.UserData.ClientModule, TargetHumanoid, TargetTorso, RaycastResult.Instance, RaycastResult.Instance.Size, Cast.UserData.Misc, Distance, Target)

here are some variables

local Distance = (RaycastResult.Position - Origin).Magnitude
local Target = RaycastResult.Instance:FindFirstAncestorOfClass("Model")
local TargetHumanoid = Target and Target:FindFirstChildOfClass("Humanoid")
local TargetTorso = Target and (Target:FindFirstChild("HumanoidRootPart") or Target:FindFirstChild("Head"))

What is the server invoking because somewhere in your script you are adding a number to something that isn’t a number like an instance.

Do you mean this?

InflictTarget.OnServerInvoke = function(Player, Type, ...)
	if Type == "Gun" then
		InflictGun(Player, ...)
	elseif Type == "GunMelee" then
		InflictGunMelee(Player, ...)
	end
end

Can you show us the entire script? There are some functions and it doesn’t help that we don’t know what those do. The downside of using remotes is that when there’s a error, the game will say that it’s the line that called the remote.

The error says that somewhere you have added a number to an instance or a string so it can not complete the addition. Search the script for where you do math.

(It doesn’t have to be addition)

1 Like

You’ve attempted to multiply a number by something that doesn’t exist - double check any properties or variables you might be using - I’d recommend just printing anything to see whats not being stored properly.

Man the code is like 1500 lines long :cry:

Send a screenshot of the whole error and we might be able to help.

Use the find tool to search the whole script for multiplication.

Found the issue. I was making a new game using an old gun system and it had an event going on so i used an _g for the multiplier. It wasnt here in the new game

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