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

Help with body velocity/animation function! [?]

I have this if statement inside of a function and its supposed to make you do a side flip, but it only flips you on the x axis. Let's say you are facing the x axis, the animation would make you flip sideways, but you would be going forward, I want to know how I could make the body velocity change relative to the characters torso. what's going on

if char and char.Humanoid then
		local anim = char.Humanoid:LoadAnimation(char:FindFirstChild("LJumpAnim"))
		anim:Play()
		local bodyVelocity = Instance.new("BodyVelocity",char.Torso)
		bodyVelocity.Velocity = Vector3.new(-15,-1,0)
		bodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
		wait(1.3)
		bodyVelocity:remove()
		debounce = true
	end

Help is appreciated

1 comment

1 answer

bodyVelocity.Velocity = Vector3.new(-15,-1,0)

You're setting the velocity to a world coordinate, its like telling someone to do a flip towards north. No matter where you're facing you'll always move towards north. You have to offset it from the players position/direction.

bodyVelocity.Velocity = char.Torso.Position + Vector3.new(-15,-1,0)

I don't know if that will work since i'm not very good with vectors, but it's supposed to be something like that.

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