How would I use VectorForce to fling / push a player in a direction?

My current code doesn’t move the character, I assume it’s something with mass the number doesn’t change much:

			local Character = Player.Character
			local force = Instance.new("VectorForce")
			local att0 = Instance.new("Attachment")
			
			att0.Parent = Character.PrimaryPart
			
			force.Attachment0 = att0
			force.Parent = Character.PrimaryPart
			
			force.Force = Character.PrimaryPart.CFrame.LookVector * 1000

			force.ApplyAtCenterOfMass = true

			force.RelativeTo = Enum.ActuatorRelativeTo.World

Would appreciate help with explaination

1 Like

Would this help?

local Character = game.Players.LocalPlayer.Character
local force = Instance.new("VectorForce")
local att0 = Instance.new("Attachment")
local Mass = Character.PrimaryPart.AssemblyMass
att0.Parent = Character.PrimaryPart

force.Attachment0 = att0
force.Parent = Character.PrimaryPart

force.Force = Character.PrimaryPart.CFrame.LookVector * Mass ^ 3 -- Mass relates to the needed amount of force to make the "thing" move, so why not power it by 3, which gives us a good/big number.


force.ApplyAtCenterOfMass = true

force.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
1 Like

To get the player to move in the desired direction, you need to set the Force property of the VectorForce object to the desired direction multiplied by a desired magnitude.
For example, if you want the player to move in the direction of the character’s PrimaryPart’s LookVector, multiplied by 1000, then you can use the following code:
“This is an example”

local Character = Player.Character
local force = Instance.new("VectorForce")
local att0 = Instance.new("Attachment")

att0.Parent = Character.PrimaryPart

force.Attachment0 = att0
force.Parent = Character.PrimaryPart

force.Force = Character.PrimaryPart.CFrame.LookVector * 1000

force.ApplyAtCenterOfMass = true
force.RelativeTo = Enum.ActuatorRelativeTo.World

This will apply a force in the direction of the Character’s LookVector multiplied by 1000, starting from the Character’s PrimaryPart.

9 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.