How i could REALLY replace a animation?

Hey! I recently created a Moving and Keybind Running system, And the Run animation dont really replace the walk animation, Why? Because when any animation calls the event “step” it plays a footstep sound, But like i said, The walk anim dont go away and it still print events, So the footsteps hear double, So, What is the best way to REALLY replace the animation?

Video example:
https://vimeo.com/manage/videos/978626574/privacy
(Sorry for bad quality)

My running system script:

-- Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")

-- Extra Instances
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")

local Animation = Humanoid:LoadAnimation(script.RunAnim)

local CanRun = true
local Running = false
local HasPlayedAnimation = false

local userAnimateScaleRunSuccess, userAnimateScaleRunValue = pcall(function() return UserSettings():IsUserFeatureEnabled("UserAnimateScaleRun") end)
local userAnimateScaleRun = userAnimateScaleRunSuccess and userAnimateScaleRunValue

local EventFolder = ReplicatedStorage:WaitForChild("GameEvents")

-- Tables
local Table1 = {}

-- Code


local function getRigScale()
	if userAnimateScaleRun then
		return Character:GetScale()
	else
		return 1
	end
end

UserInputService.InputBegan:Connect(function(input, gpe)
	if CanRun and input.KeyCode == Enum.KeyCode.LeftShift and not gpe then
		Running = true
		Humanoid.WalkSpeed += 8
	end
end)

UserInputService.InputEnded:Connect(function(input, gpe)
	if CanRun and input.KeyCode == Enum.KeyCode.LeftShift and not gpe then
		Running = false
		Humanoid.WalkSpeed -= 8
		Animation:Stop(0.3)
		HasPlayedAnimation = false
	end
end)


RunService.RenderStepped:Connect(function()
	local Humanoid = Character:FindFirstChild("Humanoid");
	if Humanoid then
		if Humanoid.MoveDirection.Magnitude == 0 then
			Animation:Stop(0.3)
			HasPlayedAnimation = false
		elseif HasPlayedAnimation ~= true and Humanoid.MoveDirection.Magnitude > 0 and Running == true then
			Animation:Play(0.5)
			HasPlayedAnimation = true
		end
	end
end)

--[[
	This script is part from Kolda Studios! Please do NOT modify any code in here.
	Also pls dont rob it :p
]]
1 Like

call :Stop() on the walk animation when you start the run animation

and do the same thing for the walk animation

1 Like

Yeah, But there is any way to do it without remoteEvents? Because the walk animations plays in Animate Script

1 Like

you use bindable events to communicate between 2 client scripts

you could put both the walk and run animation in the same script

1 Like

You don’t need to stop them, just set the priority of the run animation higher than the walk one, so it will override it. You can do this from both script and animation editor.

1 Like

idk if the animation events will still fire when the animation is overrided though

they are trying to get rid of the footstep sounds

1 Like

Nope, I set Running animation priority to action4 and walk anim is Movement, and it stills printing the walk footsteps

1 Like

Why not use a boolean variable to check when the user is running? So the step event first checks if the user is running before continuing the code.

1 Like

Good idea! Lemme try that.
One second

1 Like

That worked! Thank you so much!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.