Animated 2D morph problem?

Okay, I’ll go straight to the point and say that I pretty much am trying to well “fix” an existing morph asset because well, the script is pretty much strange that and I am a beginner at this: 2D Morph Template Robot - Roblox

  1. What do you want to achieve?
    Have the animation of the morph itself start the instant a player moves and stop when the player stops moving.

  2. What is the issue?
    To put it simple, it haves a small delay for the animation to actually start AND stop, I’ve been pulling my hair trying to think of a solution.

  3. What solutions have you tried so far?

Looking further at the code I tried to change “while go” to “while running” but that would break the animation and I doubt other solutions I thought of would do anything, again, I am a complete beginner and this and some help would be really appreciated. <3

-- Config --
--------------------------
StandingID = "http://www.roblox.com/asset/?id=5707398901"	-- Pic 1 IDLE
Walking1ID = "http://www.roblox.com/asset/?id=5707399015"	-- Pic 2 Left Pose ,Start Cycle
Walking2ID = "http://www.roblox.com/asset/?id=5707399106"	-- Pic 3 Right Pose, Between
Walking3ID = "http://www.roblox.com/asset/?id=5707399015"	-- Pic 2 Left Pose, End Cycle
JumpingID = "http://www.roblox.com/asset/?id=5707399015"	-- Pic 2 Left Pose
FallingID = "http://www.roblox.com/asset/?id=5707399015"	-- Pic 2 Left Pose
--------------------------

-- Bools, Debounces, Tags --

running = true
jumping = false
betweencycle = false
local hum = script.Parent.Parent:FindFirstChild("Humanoid")
local pose = script.Parent:FindFirstChild("PoseBool")
local df = script.Parent.DecalFront
local db = script.Parent.DecalBack
local go = false
--------------------------
-- P.S Name the decal on the front, DecalFront and decal on back, DecalBack.
-- Functions --

function Move(speed)
	 if speed > 0 then
		running = true
	else
		running = false
		df.Texture = StandingID
		db.Texture = StandingID
	end
end

function Jumped()
	df.Texture = Walking1ID
	db.Texture = Walking1ID
	jumping = false
	wait(0.6)
	jumping = false
	df.Texture = Walking1ID
	db.Texture = Walking1ID
end

function Fall()
	if jumping == false then
		df.Texture = Walking1ID
		db.Texture = Walking1ID
	end
end

hum.Running:connect(Move)
hum.Jumping:connect(Jumped)
hum.FreeFalling:connect(Fall)
--------------------------

if game.Players:FindFirstChild(script.Parent.Parent.Name) ~= nil then
	go = true
end

-- Loop --

while go do
	wait(0.15)
	if running and pose.Value == false then
		if df.Texture == StandingID then
			df.Texture = Walking1ID
		elseif df.Texture == Walking1ID then
				df.Texture = Walking2ID
				betweencycle = true
		elseif df.Texture == Walking2ID and betweencycle then
				df.Texture = Walking3ID
				betweencycle = false
		elseif df.Texture == Walking2ID and betweencycle == false then
				df.Texture = Walking1ID
		elseif df.Texture == Walking3ID then
				df.Texture = Walking2ID
		end
	end
	db.Texture = df.Texture
end

Change

while go do
	wait(0.15)
	if running and pose.Value == false then
		if df.Texture == StandingID then
			df.Texture = Walking1ID
		elseif df.Texture == Walking1ID then
				df.Texture = Walking2ID
				betweencycle = true
		elseif df.Texture == Walking2ID and betweencycle then
				df.Texture = Walking3ID
				betweencycle = false
		elseif df.Texture == Walking2ID and betweencycle == false then
				df.Texture = Walking1ID
		elseif df.Texture == Walking3ID then
				df.Texture = Walking2ID
		end
	end
	db.Texture = df.Texture
end

to

game:GetService("RunService").RenderStepped:Connect(function() --you might need to change RenderStepped to Heartbeat because idk the type of script your using
	if not go then return end
	task.wait(.15)
	if running and pose.Value == false then
		if df.Texture == StandingID then
			df.Texture = Walking1ID
		elseif df.Texture == Walking1ID then
				df.Texture = Walking2ID
				betweencycle = true
		elseif df.Texture == Walking2ID and betweencycle then
				df.Texture = Walking3ID
				betweencycle = false
		elseif df.Texture == Walking2ID and betweencycle == false then
				df.Texture = Walking1ID
		elseif df.Texture == Walking3ID then
				df.Texture = Walking2ID
		end
	end
	db.Texture = df.Texture
end)
2 Likes

Thanks for the reply but unfortunately it kind of broke the animation further, the problem still persisting.

The script I provided is of the animation process itself, in how the decal animation works.

first of all: is this in a LocalScript? if not, well, it should be in a LocalScript.

secondly, let’s say the loop runs every 0.15s, and they pressed the button after 0.16s. there’s a 0.14s delay until the next loop or worse. you want to restart the loop every time it moves, and end it every time it stops, so as soon as they hit the button, it never waits for an arbitrary number of seconds. remove the bottom loop, and redo your Move handler:

local running = false
function Move(speed)
	if speed > 0 and not running then
		running = true
		while running and pose.Value == false do
			-- blah blah blah
			db.Texture = df.Texture
			task.wait(0.15)
		end
	elseif running then
		running = false
		df.Texture = StandingID
		db.Texture = StandingID
	end
end
1 Like

Thank you for the response but it doesn’t do the trick either, it kind of breaks the animation as well, at this point I might end up having to make my own loop script for it because now that I look at it seems inefficient, but I am really thankful for the reply.

I don’t mind if anyone really sets this as solved even though it really isn’t.

we can troubleshoot it. in what way is it broken? mind sending me a snap of your new source code?

Bumping post because I’m having the same issue… Have u figured out a way to make it work??