So today I was working on making a simple function that can apply the correct amount of force onto a cart I made and I had no errors with it when I tested my code, there is a BodyForce object within the car model that has its value changed according to the function and I don't understand why it isn't working correctly.
Force equation: Force = Mass * Acceleration
Also, I have my car within a model, and all the parts within that models are normal parts (No unions involved.)
Here is my code:
-- Variables
local Acceleration = Vector3.new(4.905, 0, 0)
local BodyForce = script.Parent.BodyForce
local Model = game.Workspace.Car
local Mass = 0
--Get mass
for _, component in pairs (Model:GetChildren()) do
if component:IsA("BasePart") then
Mass = Mass + component:GetMass()
end
end
--Apply it to the BodyForce
BodyForce.force = Acceleration * Mass

3 comments
Any errors in output?
Nope, I don't think it calculated it correctly. I don't know what values to insert for Acceleration to make it move by 1 stud
Acceleration is distance per second per second, or m/2^2... I don't understand how you're trying to apply it to a vector3.