Firing Position is nil

When I try to fire an event with a part’s position, it is nil

Code:
game.ReplicatedStorage.Event:FireServer(game.Players.LocalPlayer:GetMouse().Hit.p,script.Parent.Handle.Position)

More

I try to subtract something to it and get the error:
attempt to perform arithmetic (sub) on nil

Can you post the server script with OnClientEvent?

game.ReplicatedStorage.Event.OnServerEvent:Connect(function(plr,pos,origPos)
	local raycast = workspace:Raycast(origPos, pos - origPos * dist )
--other stuff with raycasting
	end)

You never passed origPos as a parameter.

game.ReplicatedStorage.Event:FireServer(game.Players.LocalPlayer:GetMouse().Hit.p,script.Parent.Handle.Position)

You are trying to fire a Event that receives 3 variables. 1 by default being the Player as plr and two more variables being your custom variables that are being sent from the server, which in this case you are only firing one, not two.

game.ReplicatedStorage.FireEvent:FireServer(script.Parent.Handle.Position)

the above code is only sending one variabe (besides player), the Handles Position

game.ReplicatedStorage.Event:FireServer(game.Players.LocalPlayer:GetMouse().Hit.p,script.Parent.Handle.Position)

1 Like

Where did you define the variable dist?

At the top of the script: local dist = 300