Invalid argument #3 (Vector3 expected, got Instance) when sending mouse.hit.pos over remotevent

Local script code:

local remoteEvent = game.ReplicatedStorage.RemoteEvent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()


mouse.Button1Down:Connect(function()
	
	local pos = mouse.Hit.Position
	remoteEvent:FireServer(pos)

end)

Serverside code:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(pos)
	local part = game.ReplicatedStorage.ball:Clone()

	part.Parent = game.Workspace

	part.Position = pos
end)

Change your serverside code to this:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(pos)
	local part = game.ReplicatedStorage.ball:Clone()

	part.Parent = game.Workspace

	part.Position = Vector3.new(pos)
end)

the error’s gone
but it doesn’t move and just stays in 0,0,0

First return is the player, not the position:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, pos) -- First return in the player, then any passed values
	local part = game.ReplicatedStorage.ball:Clone()

	part.Parent = game.Workspace

	part.Position = pos
end)

To prove it, print pos without changing the script:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(pos)
	print(pos) -- Your player
end)
1 Like

Didn’t see that, yeah what @VegetationBush said.

This actually helped me big time with other scripts!!!
from now on i’ll know the player always returns first!

Don’t forget, if you fire it on a client, you wouldn’t need the player in the first argument of the on server event function.