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

Cant set CFrame on shoulder more than once?

I'm trying to make a walking animation with CFrame, without the animation plugin, and since I'm new to this I don't know why I can't set the CFrame of the shoulder more than once.

Run.RenderStepped:connect(function()
	    leftArm.C1 = CFrame.new(0,0.5,-0.5) * CFrame.Angles(0,0,-math.pi/4)
		wait(2)
		leftArm.C1 = CFrame.new(0,0.5,-0.5) * CFrame.Angles(0,0,math.pi/4)
	end)

2 comments

0

The wait(2) on line 3 won't "pause" RenderStepped. The RenderStepped event will continue firing.

0

you could make it recursively run through the animation and end when it is complete, I'll type it up for you right now

1 answer

✓ Accepted answer

So I assume you want the frames to change every 2 seconds judging by your wait(2) line.

function animate(step, last)
	if step == 0 then
		leftArm.C1 = CFrame.new(0,0.5,-0.5) * CFrame.Angles(0,0,-math.pi/4)
		wait(2)
		if step ~= last then
			animate(step+1)
		end
	elseif step == 1 then
		leftArm.C1 = CFrame.new(0,0.5,-0.5) * CFrame.Angles(0,0,math.pi/4)
		wait(2)
		if step ~= last then
			animate(step+1)
		end
	end
end
	
animate(0,1)--starts off at 0 and runs until it reaches 1

The benefit of this over RenderStepped is that it allows you to add wait() commands, and also if you want to add another frame, you'd just add another elseif block with step == 2 (in this case) and then change the CFrame. The only downside I can see to this method is that if you want to add another frame in between 2 frames, you'll have to increase all of the step numbers in the blocks after the one you added by 1. But even if this was a for loop, you'd still have to do that anyway, and I just wrote it this way because I personally prefer recursive functions over standard loops.

This solution is what you are asking for, but in all honesty, learning the animation plugin is probably going to make this process a whole lot easier than you realize.

1 comment

0

Thanks, and yeah I already know how to use the animation plugin but just wanted to try this.

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