When a player presses e on their keyboard, they will be moved to the next nearest point on the wall, but this does not happen and i get the error Unable to cast double to Vector3
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local function FindNearestGrip() local grips = game.Workspace:FindFirstChild("Grips", true):GetChildren() table.sort(grips, function(a, b) dstA = (a.Position - player.Character.HumanoidRootPart.Position).magnitude dstB = (b.Position - player.Character.HumanoidRootPart.Position).magnitude return dstA < dstB end) return grips[1] end mouse.KeyDown:connect(function(key) if key == 'e' then FindNearestGrip() if dstA < dstB then player.Character:MoveTo(dstB) elseif dstB < dstA then player.Character:MoveTo(dstA) end end end)
MoveTo()
requires a Vector3
argument, you are giving it a double
.
a^2 + b^2 + C^2
is a double
, not a Vector3
.