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

BodyVelocity on Dummy NPC not working properly?

I have a dummy in the workspace, and I tested shooting a part at the player with a bodyvelocity. The problem is, is that it's not even going in the right direction sometimes towards the player, or sometimes it is, it's just crazy. I replaced the BodyVelocity with a BodyPosition to see if the same thing would happen, and the BodyPosition worked, but I just don't find it appealing.

game.Players.PlayerAdded:Connect(function(player)
	local dummy = script.Parent
	local char = game.Workspace:WaitForChild(player.Name)
	while true do
		
		local p = Instance.new("Part")
		p.Shape = "Ball"
		p.Anchored = false
		p.CanCollide = false
		p.Parent = workspace
		p.CFrame = dummy.Torso.CFrame
		local bv = Instance.new("BodyVelocity")
		bv.Parent = p
		bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
		bv.P = 500
		bv.Velocity = char.Torso.CFrame.p
		
		
		
		wait(5)
	end
end)

I also tried replacing bv.Velocity = char.Torso.Position, and the same thing happened. Any ideas?

2 answers

✓ Accepted answer

thats not how velocity works, first off, velocity works in world space, so rotation wont do anything to effect it, second, if you set velocity to the position of a part, then the x, y, and z coordinates will be transformed into velocity which does not work, if you want to make it use a position, you should be using BodyPosition, or at least use math to figure out how to get the position

1 comment

0

Thanks for the in depth explanation. I did some math by just subtracting the player torso from the dummy torso positions or the other way around. I forgot. But it works now, thanks.

you set the parent of the body velocity to workpsace instead of the dummy's lower torso

1 comment

0

The parent of the velocity is the part, not the dummys torso. It's solved either way.

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