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

help with Animation?

So i have made a function that will allow me to change the poses of a given weld or part by adjusting their cframes but how can i have it detect if it has been called while it is still running ? like for example if i made the right arm go up in 10 seconds total time waited 5 seconds then made it go down in how could i make the function detect that the first animation was not finished cancel it then execute the second animation?

here is the function

	local frames = 25

	local function newPose(joint, finishCFrame, length)
		coroutine.resume(coroutine.create(function()
			local totalDurration = length * frames		
			local i = 0
			
			while true do
				joint = joint:lerp(finishCFrame, i)
				wait(1 / frames)
				i = i + (1 / totalDurration)
				
				if i == totalDurration then break end
			end
		end))
	end

1 answer

Well one thing you could try is in your function have a variable named running and set that to false. Then in the while loop set it to true. Then when it exits the while loop set it back to false... This way you can add checks for that variable and if it is false(aka not running) then your function will allow for the animation to run else don't run the animation.

3 comments

0

how could i implement it then if i had to work with several different objects

0

and to add another layer how could i make it so some animations are overriden by some animations but not others?

0

I am unsure what you mean by different objects(scripts??) but if it is like different welds you could use a dictionary and the index would be the object you want to effect. Example running= { ["arm"]="No" } That way you can do the check for the right object... I don't know if that is what you meant.

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