Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Could someone explain this math problem in depth?

local BV = Instance.new("BodyVelocity")
BV.Parent = script.Parent
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BV.Velocity = workspace.Part.Position.Unit*50

This script has the velocity a bit offset; however if you change line 4 to this:

local BV = Instance.new("BodyVelocity")
BV.Parent = script.Parent
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BV.Velocity = (workspace.Part.Position - script.Parent.Position).Unit*50 

it works.

Why does the bottom one work but not the top one? What is happening at the bottom one?

1 answer

On the top it finds the unit in the workspace and the unit is multiplied by 50 so the BV.Velocity is 50 on the bottom it takes the position of the part and subtracts it by the scripts parents position then multiplies it and get that as the BV.Velocity

This discussion is preserved as it was. New answers, comments, and votes are closed.