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

How can I make a player walk back while looking front and playing an animation?

Well, all my questions I asked was about this, but any of those helped me and I am typing the whole thing I want.

The description of problem is: I made a punching script which a player punches another, punching player walks two studs forward while playing animation. That's okay and done. But target needs to play an animation while walking back after punching. I tried BodyGyro and :MoveTo(), since my characters are R15 it gets crazy while playing animation with BodyGyro. I tried using RenderStepped event to set CFrame of character to back(0.005 studs every step) and it got crazy by making character teleport upside and back, like player got flung. Currently all I can give here from my code is:

--RenderStepped event
local RS = game:GetService("RunService")
RS.RenderStepped:connect(function(Step)
	Pl = script.Parent.Parent
	Char = Pl.Character
	EnemyWrestler = game.Workspace:WaitForChild(Char.Indicator.Value)
	if EnemyWrestler.Unconscious.Value == true then
		aaa = EnemyWrestler.UpperTorso.Position.Y
		EnemyWrestler.UpperTorso.CFrame = CFrame.new(Vector3.new(EnemyWrestler.UpperTorso.Position.X, EnemyWrestler.UpperTorso.Position.Y, EnemyWrestler.UpperTorso.Position.Z) + (EnemyWrestler.UpperTorso.CFrame.lookVector)*-0.005)
		EnemyWrestler.UpperTorso.CFrame = CFrame.new(EnemyWrestler.UpperTorso.Position.X,aaa,EnemyWrestler.UpperTorso.Position.Z)*CFrame.Angles(math.rad(EnemyWrestler.UpperTorso.Rotation.X),math.rad(EnemyWrestler.UpperTorso.Rotation.Y),math.rad(EnemyWrestler.UpperTorso.Rotation.Z))
	end
end)

I deleted the other one, but other one was like

Animation:Play()
Humanoid:MoveTo(Vector3.new(EnemyWrestler.UpperTorso.Position.X, EnemyWrestler.UpperTorso.Position.Y, EnemyWrestler.UpperTorso.Position.Z) + (EnemyWrestler.UpperTorso.CFrame.lookVector)*-0.005))
--This may be mistaken, it's not problem it's deleted now.

If you want to know why player HAVE TO look at front while walking back, it's because animation needs to look realistic. When a person gets punched lightly, it does not spin around it crazy and turn back.

1 answer

✓ Accepted answer

There is a Humanoid property that could help, AutoRotate. Just set it false and you won't even need scripts.

2 comments

0

You are my savior. I bow infront of you.

0

Yeah, that was my reaction when I found out this property.

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