Hello!
I’m fairly new to the world of scripting, so this post might seem a little dumb or unnecessary to some more advanced scripters, but I can’t figure this error.
I’m currently working on a sort of parkour game and am trying to implement a grapple feature. The basics of it is, if the player is within range they can click on the object and grapple to it. I am currently experiencing issues with the proximity feature.
mouse.Button1Down:Connect(function()
local distance = 20 -- whatever number
if (player.Character.HumanoidRootPart.Position - GrappleObject.Position).Magnitude >= distance then
print(GrappleObject.Position)
GrappleEvent:FireServer()
print("Fired GrappleEvent")
else
-- dont grapple
end
end)
Every time I attempt to grapple to the part I get returned with this error:
Workspace.Player.Grapple:16: attempt to perform arithmetic (sub) on Vector3 and nil
The error is being caused on this line:
if (player.Character.HumanoidRootPart.Position - GrappleObject.Position).Magnitude >= distance
Its probably a simple solution, I just can’t find it.