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

How to add constant force to the player's humanoidrootpart successfully?

Hi, I'm making a game where when the player touches a part, forces are applied to their HumanoidRootPart, which creates a constant force in the direction that they are facing. My current script:

script.Parent.Touched:Connect(function(touch)
	print(touch.Parent.Name)
	if touch.Parent:FindFirstChild("Humanoid") then
		print("player found!")
		local bodythrust = Instance.new("BodyThrust")
		bodythrust.Parent = touch.Parent.HumanoidRootPart
		bodythrust.Force = touch.Parent.HumanoidRootPart.CFrame.LookVector
	end
end)

I'm not entirely sure what force type to use, and I'm not sure what properties to use. I've looked at many dev forum articles on different types of forces, but I couldn't really find anything I was looking for. I have the force as the look vector which is probably the problem, but I don't want to multiply that (using * 2) because it needs to have the same amount of force all the time.

1 answer

Solved my own question lol

script.Parent.Touched:Connect(function(touch)
	print(touch.Parent.Name)
	if touch.Parent:FindFirstChild("Humanoid") then
		print("player found!")
		if touch.Parent.HumanoidRootPart:FindFirstChild("BodyThrust") then
			print("this player already has a bodythrust")
		else
			local bodythrust = Instance.new("BodyThrust")
			bodythrust.Parent = touch.Parent.HumanoidRootPart
			bodythrust.Force = touch.Parent.HumanoidRootPart.CFrame.LookVector
			bodythrust.Force = Vector3.new(bodythrust.Force.X * 4000, bodythrust.Force.Y * 4000, bodythrust.Force.Z * 4000)
		end
	end
end)

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