Animation Speed Change?

Hello, so me and my friend remade this kit but there’s a slight problem.
the animation speed has a big change.

Original Kit:


Me and my friends Version:


I’m not sure if you see the difference but I can. its way faster and more choppy, less smooth.

i can show more videos of the original.
also if you need both source codes ill send both if you’d like.

it would be helpful to see some code examples. its not really possible to tell you whats wrong from looking at videos

alright. ill send both source codes.

NEW kit – really long

local UIS = game:GetService("UserInputService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local hmr = character:WaitForChild("HumanoidRootPart")
local gui = player.PlayerGui.FnfGui
local camera = workspace.CurrentCamera

local LocalFolder = game:GetService("ReplicatedStorage").Local
local keybinding = require(LocalFolder.Keybinding)
local keybindsFolder = LocalFolder.Keybinds
local newKeybind = keybinding.new(keybindsFolder)

local mic = script.Parent
local micEquipped = false

local animationTrack
local animationObject = Instance.new("Animation")
animationObject.Name = "NormalAnimation"
animationObject.Parent = mic
local idle = "rbxassetid://" .. mic:GetAttribute("IdleAnimation")

function getInputDir(keyCode)

	return newKeybind.get(keyCode)
end

local playAnim = {}
function playAnimation(id)
		playAnim[id] = true
		animationObject.AnimationId = id
		
		if animationTrack ~= nil then
			if animationTrack.IsPlaying and animationTrack.Animation.AnimationId ~= id then
				animationTrack:Disconnect()
			end
		end
		animationTrack = humanoid.Animator:LoadAnimation(animationObject)
		animationTrack:Play(0)
		
		local onStop
		onStop = animationTrack.Stopped:Connect(function()
			playAnim[id] = false
			onStop:Stop()
		end)
end

local highlightedImg = {}
function highlightImage(image,state)
	if not highlightedImg[image.Name] then
		local arrowColors = {
			UpArrow = Color3.fromRGB(0,255,0),
			LeftArrow = Color3.fromRGB(255,0,255),
			DownArrow = Color3.fromRGB(0,64,255),
			RightArrow = Color3.fromRGB(255,0,0),
		}
		
		
		highlightedImg[image.Name] = true
		if state == nil then
			spawn(function()
				local tweenIn = game:GetService("TweenService"):Create(image, TweenInfo.new(0.05), {ImageColor3 = Color3.fromRGB(255,255,255),ImageTransparency = 0})
				tweenIn:Play()
				tweenIn.Completed:Wait()
				local tweenOut = game:GetService("TweenService"):Create(image, TweenInfo.new(0.05), {ImageColor3 = Color3.fromRGB(100,100,100),ImageTransparency = 1})
				tweenOut:Play()
				tweenOut.Completed:Wait(0.7)
				highlightedImg[image.Name] = false
			end)
		elseif state == "In" then
			spawn(function()
				local tweenIn = game:GetService("TweenService"):Create(image, TweenInfo.new(0.05), {ImageColor3 = Color3.fromRGB(255,255,255),ImageTransparency = 0})
				tweenIn:Play()
				tweenIn.Completed:Wait(0.7)
			end)
		elseif state == "Out" then
			spawn(function()
				local tweenOut = game:GetService("TweenService"):Create(image, TweenInfo.new(0.05), {ImageColor3 = Color3.fromRGB(100,100,100),ImageTransparency = 1})
				tweenOut:Play()
				tweenOut.Completed:Wait(0.7)
				highlightedImg[image.Name] = false
			end)
		end
	end
	
	if state == "Out" and highlightedImg[image.Name] then
		spawn(function()
			local tweenOut = game:GetService("TweenService"):Create(image, TweenInfo.new(0.05), {ImageColor3 = Color3.fromRGB(100,100,100),ImageTransparency = 1})
			tweenOut:Play()
			tweenOut.Completed:Wait(0.7)
			highlightedImg[image.Name] = false
		end)
	end
end

mic.Equipped:Connect(function()
	micEquipped = true
	humanoid.WalkSpeed = 0
	humanoid.JumpPower = 0
	playAnimation(idle)
	gui.Enabled = true
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = hmr.CFrame + hmr.CFrame.RightVector * 13
	camera.CFrame = CFrame.lookAt(camera.CFrame.Position, hmr.Position)
	if gui.Enabled == false then
		gui.Enabled = true
	end
end)

mic.Unequipped:Connect(function()
	if humanoid:FindFirstChild("Animator") ~= nil then
		for _i,aTrack in pairs(humanoid.Animator:GetPlayingAnimationTracks()) do
			aTrack:Stop()
		end	
	end
	micEquipped = false
	humanoid.WalkSpeed = 16
	humanoid.JumpPower = 50
	local activeTracks = humanoid:GetPlayingAnimationTracks()
	for _,v in pairs(activeTracks) do
		v:Stop()
	end
	gui.Enabled = false
	camera.CameraType = Enum.CameraType.Custom
	if gui.Enabled == true then
		gui.Enabled = false
	end
end)
local direction
local allKeysHeld = {}
local isKeyHoldRunning = false
	
local function keyHold()
	if not isKeyHoldRunning then
		isKeyHoldRunning = true
		local validKeys = newKeybind.getKeys()
		local function validKeyPressed()
			local status = false
			
			for key,action in pairs(validKeys) do
				if allKeysHeld[Enum.KeyCode[key]] then
					status = true
					break
				end
			end
			return status
		end
		local function playLoopedAnimation()
			for key,action in pairs(validKeys) do
				if allKeysHeld[Enum.KeyCode[key]] then
					direction = getInputDir(Enum.KeyCode[key])
					if direction ~= nil and direction ~= "No key!" then
						playAnimation("rbxassetid://" .. mic:GetAttribute(direction .. "Animation"))
					end
				end
			end
		end
		local function highlightHeldArrow()
			for key,action in pairs(validKeys) do
				if allKeysHeld[Enum.KeyCode[key]] then
					highlightImage(gui.GlowArrows:FindFirstChild(action .. "Arrow"),"In")
				else
					highlightImage(gui.GlowArrows:FindFirstChild(action .. "Arrow"),"Out")
				end
			end
		end
		while validKeyPressed() do
			task.wait()
			highlightHeldArrow()
			playLoopedAnimation()
		end
		highlightHeldArrow()
		isKeyHoldRunning = false
	end
end

local mobileIsRunning = {}
local function mobileSupport(arrow,state,input,click)
	if micEquipped then
		if (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch) then
			if not mobileIsRunning[arrow.Name] and state == "In" then
				mobileIsRunning[arrow.Name] = true
				direction = string.gsub(arrow.Name,"Arrow","")
				local key = newKeybind.getKeyFromAction(direction)
				allKeysHeld[Enum.KeyCode[key]] = true
				keyHold()
				if direction ~= nil and direction ~= "No key!" then
					playAnimation("rbxassetid://" .. mic:GetAttribute(direction .. "Animation"))
					highlightImage(gui.GlowArrows:FindFirstChild(direction .. "Arrow"))
				end

			end
		end
	end
	if mobileIsRunning[arrow.Name] and state == "Out" then
		direction = string.gsub(arrow.Name,"Arrow","")
		local key = newKeybind.getKeyFromAction(direction)
		allKeysHeld[Enum.KeyCode[key]] = false
		mobileIsRunning[arrow.Name] = false
	end
end

UIS.InputBegan:Connect(function(input)
	if micEquipped then
		if (input.UserInputType == Enum.UserInputType.Keyboard) then
			direction = getInputDir(input.KeyCode)
			allKeysHeld[input.KeyCode] = true
			keyHold()
			if direction ~= nil and direction ~= "No key!" then
				playAnimation("rbxassetid://" .. mic:GetAttribute(direction .. "Animation"))
				highlightImage(gui.GlowArrows:FindFirstChild(direction .. "Arrow"))
			end
		
		end
	end
end)

UIS.InputEnded:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		allKeysHeld[input.KeyCode] = false
	end
	if animationTrack ~= nil then
		if animationTrack.IsPlaying then
			local onStop
			onStop = animationTrack.Stopped:Connect(function()
				onStop:Disconnect()
			end)

		end
	end
end)

local arrowHitboxUpEvents = {}
local arrowHitboxDownEvents = {}
for _i,arrowHitbox in pairs(gui.MobileArrows:GetChildren()) do
	arrowHitboxDownEvents[_i] = arrowHitbox.InputBegan:Connect(function(input,click)
		mobileSupport(arrowHitbox,"In",input,click)
	end)

	arrowHitboxUpEvents[_i] = arrowHitbox.InputEnded:Connect(function(input,click)
		mobileSupport(arrowHitbox,"Out",input,click)
	end)
end

old kit

local UIS = game:GetService("UserInputService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local hmr = character:WaitForChild("HumanoidRootPart")
local gui = player.PlayerGui.FnfGui
local camera = workspace.CurrentCamera

local LocalFolder = game:GetService("ReplicatedStorage").Local
local keybinding = require(LocalFolder.Keybinding)
local keybindsFolder = LocalFolder.Keybinds
local newKeybind = keybinding.new(keybindsFolder)

local mic = script.Parent
local micEquipped = false

local animationTrack
local animationObject = Instance.new("Animation")
animationObject.Parent = mic
local idle = "rbxassetid://" .. mic:GetAttribute("IdleAnimation")

function getInputDir(keyCode)

	return newKeybind.get(keyCode)
end

function playAnimation(id)
	animationObject.AnimationId = id
	animationTrack = humanoid.Animator:LoadAnimation(animationObject)
	animationTrack:Play(0)
end

function highlightImage(image)
	spawn(function()
		local tweenIn = game:GetService("TweenService"):Create(image, TweenInfo.new(0.1), {ImageColor3 = Color3.fromRGB(255,255,255)})
		tweenIn:Play()
		tweenIn.Completed:Wait()
		local tweenOut = game:GetService("TweenService"):Create(image, TweenInfo.new(0.1), {ImageColor3 = Color3.fromRGB(100,100,100)})
		tweenOut:Play()
	end)
end

mic.Equipped:Connect(function()
	micEquipped = true
	humanoid.WalkSpeed = 0
	humanoid.JumpPower = 0
	playAnimation(idle)
	gui.Enabled = true
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = hmr.CFrame + hmr.CFrame.RightVector * 13
	camera.CFrame = CFrame.lookAt(camera.CFrame.Position, hmr.Position)
end)

mic.Unequipped:Connect(function()
	micEquipped = false
	humanoid.WalkSpeed = 16
	humanoid.JumpPower = 50
	local activeTracks = humanoid:GetPlayingAnimationTracks()
	for _,v in pairs(activeTracks) do
		v:Stop()
	end
	gui.Enabled = false
	camera.CameraType = Enum.CameraType.Custom
end)

UIS.InputBegan:Connect(function(input)
	if micEquipped and 
		(input.UserInputType == Enum.UserInputType.Keyboard) then

		local direction = getInputDir(input.KeyCode)
		print(direction)
		if direction ~= nil then
			playAnimation("rbxassetid://" .. mic:GetAttribute(direction .. "Animation"))
			highlightImage(gui.Arrows:FindFirstChild(direction .. "Arrow"))
		end
	end
end)

btw if you’re wondering this is the main part of the script
which enables the animations obv

if i put nothing on play() it will go to snap animation
which i dont like.
if i put play(0) it will be fast which doesn’t happen on the original one

i believe its mainly the

animationTrack:Play(0)

that is what i was about to say. im pretty sure its because of that line as well. you can use AnimationTrack:AdjustSpeed() to fix this. i assume putting a number like 0.1 would make the anim play 10x slower. from what ive read 0 would pause the animation being played, but i will look into your code a bit more to see if i can find another solution.

i will check out the adjust speed.

by the way, 0.1 is snap animation which is kinda weird to me

is there a chance that it’s your animation and not your script?

no, i used the same animation with both scripts. they look completely different on each one

try:

animationTrack:Play(0,1,--speed value here)

hm, seems to be the same problem. is there any way i can replace the messed up code with the old one

or mix them up

char limt

you can try replacing the playAnimation() function with the code from the previous script. i dont see how this would solve the problem but roblox is a little weird with things like that so it may work because as far as im concerned both of the scripts functions take the same parameters

it works but like, once i add the keyHold function into the direction part it ends up doing the same thing

does the animation loop even without the keyhold function? im not sure why but it looks like youre constantly playing the animation over and over again. (maybe thats not your intent that just what i got from looking at the code if not please correct me)

it will not loop without the key hold function. im constantly playing it to show the speed difference.

but honestly. it looks fine now : ) thanks for the support have a good night or day

im gonna close the topic because im code sensitive lol

haha sorry i could help you find a solution! good luck with your game it looks great!