I tried to work with math functions but didn't went well

What do I want achieve?

I just want to make a subtration function. Which points go from A - B.

Can you show us what you mean?

So the Blue should go to the Yellow. I want use Parts instead of models

image

Why is your function not working? and what have you been tried so far?

The Problem is that I dont know how I can make a subtration function. So can you help?

local function Vectorsub(Va, Vb)
	local v = Vector3.new()
	v.Position = Va.Position.X - Vb.Position.X
	v.Position = Va.Position.Y - Vb.Position.Y
	v.Position = Va.Position.Z - Vb.Position.Z
	return v	
end

local Part1 = game.Workspace.Part1
local Part2 = game.Workspace.Part2

Vectorsub(Part1.Position, Part2.Position)

You can’t edit a Vector3 after it’s been created. Return Vb - Va in your subtraction function to get the difference.

Use the pythagorean theroem.
It can help calculate the distance of c

1 Like

Yes. But I dont want solve it with a pythagorean theroem can you help me with my function?

v = P - I

Assuming that ‘v’, ‘P’ and ‘I’ are all Vector3s.

While you create the Vector3 assign the 3 values to it instead of doing it in the next chunk

you can do this (V1 - V2).Mangnitude

did it work?

2 Likes