Error with magnitude

hi, I have a script and the error is “ServerScriptService.Tools.PickaxeScript:13: attempt to perform arithmetic (sub) on number and Vector3”

image

Firstly, instead of posting the code via screenshot, paste it using the ``` syntax.

Could you try printing mousePos? The issue is most likely with that. Could you also give both Client/Server scripts.

Mouse pos: 212.29385375976562

server script: ```local RS = game:GetService(“ReplicatedStorage”)

local events = RS:FindFirstChild(“Events”)

local event = events:FindFirstChild(“PickaxeEvent”)

event.OnServerEvent:Connect(function(player, mousePos)

local character = player.Character or player.CharacterAdded:Wait()

local leftHand = character:FindFirstChild("LeftHand")

print(mousePos)

if (mousePos - leftHand.Position).Magnitude < 12 then
	
	local explosion = Instance.new("Explosion")
	explosion.Parent = workspace
	explosion.BlastPressure = 20
	explosion.BlastRadius = 20
	explosion.DestroyJointRadiusPercent = 0
	explosion.ExplosionType = Enum.ExplosionType.Craters
	explosion.Visible = false
	explosion.Position = mousePos
	
end

end)```

Client Script:


local players = game:GetService("Players")
local player = players.LocalPlayer

local mouse = player:GetMouse()

local RS = game:GetService("ReplicatedStorage")

local events = RS:FindFirstChild("Events")

local event = events:FindFirstChild("PickaxeEvent")

tool.Activated:Connect(function()
	
	event:FireServer(mouse.Hit.Position)
	
end)```

You can’t compare vector3 together, compare only x / y / z value

make sure mousePos is a vector3 value, try printing it

and also instead of doing character:findfirstchild just do character.LeftHand (this will find the left hand of an r15 character)