Roblox animation overriding my animations or my animations do not work

Recently, I have been having issues with animations in my game, It all started from when I had removed the default rig in my game so that players could use a normal avatar, But now, Roblox animations have been overriding mine, Or such animations, (Like idle), Don’t play, Does anyone know a fix or solution?

Example Video:

External Media

Character Script:

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local root = char:WaitForChild("HumanoidRootPart")
local cam = workspace.CurrentCamera

local alive = true

hum.AutoJumpEnabled = false

hum.Died:Connect(function()
	alive = false
	cam.CameraType = Enum.CameraType.Custom
end)

char.AncestryChanged:Connect(function(_, parent)
	if not parent then
		alive = false
	end
end)

local TS = game:GetService("TweenService")
local RS = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local SS = game:GetService("SoundService")

local WALK_SPEED = 16
local SPRINT_SPEED = 25
local DASH_POWER = 70
local DASH_COOLDOWN = 1.2
local SLIDE_SPEED = 50        
local SLIDE_DURATION = 0.8
local SLIDE_COOLDOWN = 1
local ANIM_FADE = 0.3
local LAND_RECOVERY_TIME = 1

local MAX_STAMINA = 100
local STAMINA_REGEN = 15     
local SPRINT_COST = 10       
local DASH_COST = 25         
local SLIDE_COST = 15        
local JUMP_COST = 10         

local BASE_FOV = 70
local SPRINT_FOV = 85
local SLIDE_FOV = 90

local shiftLockEnabled = false
local isSprinting = false
local isRolling = false
local isSliding = false
local canSlide = true 
local canDash = true
local isInAir = false
local sprintQueued = false 
local currentStamina = MAX_STAMINA


local sprintInputHeld = false 

local currentSlideTask = nil 
local slideBodyVel = nil 

local events = game.ReplicatedStorage:WaitForChild("Events")
local sounds = game.ReplicatedStorage:WaitForChild("Sounds")

local landingVfxEvent = events:WaitForChild("landingVfxEvent")
local soundEvent = events:WaitForChild("SoundEvent")
local slideSound = sounds:WaitForChild("SlideSound")

local anims = {
	WalkFront = animator:LoadAnimation(game.ReplicatedStorage.Animations.FrontWalkAnim),
	WalkLeft = animator:LoadAnimation(game.ReplicatedStorage.Animations.LeftWalkAnim),
	WalkRight = animator:LoadAnimation(game.ReplicatedStorage.Animations.RightWalkAnim),
	WalkBack = animator:LoadAnimation(game.ReplicatedStorage.Animations.BackWalkAnim),
	Sprint = animator:LoadAnimation(game.ReplicatedStorage.Animations.SprintAnim),
	Land = animator:LoadAnimation(game.ReplicatedStorage.Animations.LandAnim),
	Slide = animator:LoadAnimation(game.ReplicatedStorage.Animations.Slide), 
	RollFront = animator:LoadAnimation(game.ReplicatedStorage.Animations.FrontRoll),
	RollBack = animator:LoadAnimation(game.ReplicatedStorage.Animations.BackRoll),
	RollLeft = animator:LoadAnimation(game.ReplicatedStorage.Animations.LeftRoll),
	RollRight = animator:LoadAnimation(game.ReplicatedStorage.Animations.RightRoll)
}


for _, anim in pairs(anims) do
	anim.Priority = Enum.AnimationPriority.Action
end

local staminaGui = Instance.new("ScreenGui")
staminaGui.Name = "StaminaGUI"
staminaGui.ResetOnSpawn = false
staminaGui.Parent = player:WaitForChild("PlayerGui")

local barBg = Instance.new("Frame")
barBg.Name = "Background"
barBg.Size = UDim2.new(0, 300, 0, 20)
barBg.Position = UDim2.new(0, 20, 0.95, -20) 
barBg.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
barBg.BorderSizePixel = 0
barBg.Parent = staminaGui

local barFill = Instance.new("Frame")
barFill.Name = "Fill"
barFill.Size = UDim2.new(1, 0, 1, 0)
barFill.BackgroundColor3 = Color3.fromRGB(255, 255, 255) 
barFill.BorderSizePixel = 0
barFill.Parent = barBg

local uiStroke = Instance.new("UIStroke")
uiStroke.Parent = barBg
uiStroke.Thickness = 2
uiStroke.Color = Color3.fromRGB(0, 0, 0)

local function muteMovementSounds()
	soundEvent:FireServer("StopSprintSound")
end

local function stopMovementAnims()
	for _, anim in pairs({anims.WalkFront, anims.WalkLeft, anims.WalkRight, anims.WalkBack, anims.Sprint, anims.Slide}) do
		anim:Stop(ANIM_FADE)
	end
end

local function canSprintCheck()
	local moving = hum.MoveDirection.Magnitude > 0.05
	return moving and currentStamina > 0
end

local function stopSprinting()
	isSprinting = false
	sprintQueued = false
	if not isSliding then
		hum.WalkSpeed = WALK_SPEED
	end
	soundEvent:FireServer("StopSprintSound")
end

local function updateAnims()
	if isRolling or isSliding or isInAir then return end

	if isSprinting and not canSprintCheck() then
		stopSprinting()
	end

	local moving = hum.MoveDirection.Magnitude > 0.05
	if not moving then 
		stopMovementAnims() 
		return 
	end

	if isSprinting or sprintQueued then
		if not anims.Sprint.IsPlaying then 
			stopMovementAnims() 
			anims.Sprint:Play(ANIM_FADE) 
			soundEvent:FireServer("SprintSound") 
		end
	elseif shiftLockEnabled then
		local relDir = root.CFrame:VectorToObjectSpace(hum.MoveDirection)
		local targetAnim = anims.WalkFront

		if math.abs(relDir.X) > math.abs(relDir.Z) then
			targetAnim = relDir.X > 0 and anims.WalkRight or anims.WalkLeft
		else
			targetAnim = relDir.Z > 0 and anims.WalkBack or anims.WalkFront
		end

		if not targetAnim.IsPlaying then
			stopMovementAnims()
			targetAnim:Play(ANIM_FADE)
		end
	else
		if not anims.WalkFront.IsPlaying then 
			stopMovementAnims() 
			anims.WalkFront:Play(ANIM_FADE) 
		end
	end
end

local function toggleShiftLock(state)
	shiftLockEnabled = state
	hum.AutoRotate = not state
	if not UIS.TouchEnabled then
		if state then
			UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
			UIS.MouseIcon = "rbxassetid://16481167971"
		else
			UIS.MouseBehavior = Enum.MouseBehavior.Default
			UIS.MouseIcon = "rbxassetid://129875024"
		end
	end
	updateAnims()
	if game.ReplicatedStorage:FindFirstChild("Sounds") and game.ReplicatedStorage.Sounds:FindFirstChild("ShiftLockSound") then
		game.ReplicatedStorage.Sounds.ShiftLockSound:Play()
	end
end

local function endSlide(wasInterrupted)
	if currentSlideTask then 
		task.cancel(currentSlideTask) 
		currentSlideTask = nil
	end
	if slideBodyVel then slideBodyVel:Destroy() end
	if slideSound then slideSound:Stop() end

	anims.Slide:Stop(0.3)
	isSliding = false

	if not wasInterrupted then
		hum.WalkSpeed = isSprinting and SPRINT_SPEED or WALK_SPEED
		updateAnims()
	end
	task.delay(SLIDE_COOLDOWN, function() canSlide = true end)
end

local function performSlide(ignoreForward)
	local isMovingForward = (root.CFrame:VectorToObjectSpace(hum.MoveDirection).Z < -0.1)
	if isSliding or isInAir or (not isMovingForward and not ignoreForward) or not canSlide or currentStamina < SLIDE_COST then return end

	currentStamina = math.max(0, currentStamina - SLIDE_COST)
	isSliding = true
	canSlide = false
	isSprinting = false
	sprintQueued = isSprinting 

	game.ReplicatedStorage.Events.MovementAction:FireServer("Slide")
	muteMovementSounds()
	stopMovementAnims()

	anims.Slide:Play(0.1)
	if slideSound then slideSound:Play() end

	slideBodyVel = Instance.new("BodyVelocity")
	slideBodyVel.MaxForce = Vector3.new(1, 0, 1) * 30000
	local startSpeed = (hum.WalkSpeed >= SPRINT_SPEED) and SLIDE_SPEED or (SLIDE_SPEED * 0.7)
	slideBodyVel.Velocity = root.CFrame.LookVector * startSpeed
	slideBodyVel.Parent = root

	local tweenInfo = TweenInfo.new(SLIDE_DURATION, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out)
	TS:Create(slideBodyVel, tweenInfo, {Velocity = root.CFrame.LookVector * WALK_SPEED}):Play()

	currentSlideTask = task.delay(SLIDE_DURATION, function()
		currentSlideTask = nil 
		endSlide(false)
	end)
end

local function performDash()
	if not canDash or isRolling or isSliding or isInAir or currentStamina < DASH_COST then return end

	currentStamina = math.max(0, currentStamina - DASH_COST)
	canDash = false
	isRolling = true

	game.ReplicatedStorage.Events.MovementAction:FireServer("Dash")
	muteMovementSounds()
	soundEvent:FireServer("DashSound") 

	local moveDir = hum.MoveDirection
	local rollAnim = anims.RollFront
	local dashVel = root.CFrame.LookVector

	if moveDir.Magnitude > 0 then
		local relDir = root.CFrame:VectorToObjectSpace(moveDir)
		if math.abs(relDir.X) > math.abs(relDir.Z) then
			if relDir.X > 0 then rollAnim = anims.RollRight dashVel = root.CFrame.RightVector
			else rollAnim = anims.RollLeft dashVel = -root.CFrame.RightVector end
		else
			if relDir.Z > 0 then rollAnim = anims.RollBack dashVel = -root.CFrame.LookVector
			else rollAnim = anims.RollFront dashVel = root.CFrame.LookVector end
		end
	end

	stopMovementAnims()
	rollAnim:Play(0.1)
	root:ApplyImpulse(dashVel * DASH_POWER * root.AssemblyMass)

	task.delay(rollAnim.Length * 0.8, function()
		isRolling = false
		updateAnims()
	end)
	task.delay(DASH_COOLDOWN, function() canDash = true end)
end

local function performSlideJump()
	if not isSliding or currentStamina < JUMP_COST then return end
	currentStamina = math.max(0, currentStamina - JUMP_COST)
	endSlide(true) 
	muteMovementSounds()
	root:ApplyImpulse(Vector3.new(0, hum.JumpPower * 0.6, 0) * root.AssemblyMass)
	hum:ChangeState(Enum.HumanoidStateType.Jumping)
	if sprintInputHeld then
		sprintQueued = true 
	end
end


hum:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	if sprintInputHeld and canSprintCheck() and not isSprinting and not isSliding and not isRolling then
		isSprinting = true
		hum.WalkSpeed = SPRINT_SPEED
	end
	updateAnims()
end)

RS.RenderStepped:Connect(function(dt)
	if not root or not hum or not alive then return end

	if isSprinting and hum.MoveDirection.Magnitude > 0 and not isSliding and not isRolling then
		currentStamina = math.max(0, currentStamina - (SPRINT_COST * dt))
		if currentStamina <= 0 then stopSprinting() updateAnims() end
	else
		currentStamina = math.min(MAX_STAMINA, currentStamina + (STAMINA_REGEN * dt))
	end
	barFill.Size = UDim2.new(currentStamina / MAX_STAMINA, 0, 1, 0)

	local targetFOV = BASE_FOV
	if isSliding then targetFOV = SLIDE_FOV
	elseif isSprinting and hum.MoveDirection.Magnitude > 0 then targetFOV = SPRINT_FOV end
	cam.FieldOfView = cam.FieldOfView + (targetFOV - cam.FieldOfView) * 0.1

	if shiftLockEnabled then
		local look = cam.CFrame.LookVector
		root.CFrame = root.CFrame:Lerp(CFrame.lookAt(root.Position, root.Position + Vector3.new(look.X, 0, look.Z)), 0.4)
	end

	local targetOffset = shiftLockEnabled and Vector3.new(1.75, 0, 0) or Vector3.new(0,0,0)
	if hum.MoveDirection.Magnitude > 0 and not isInAir and not isRolling then
		local speed = isSprinting and 12 or 8
		local intensity = isSprinting and (isSliding and 0.05 or 0.35) or 0.15
		local bob = Vector3.new(math.cos(tick() * speed) * intensity, math.abs(math.sin(tick() * speed)) * intensity, 0)
		targetOffset = targetOffset + bob
	end
	hum.CameraOffset = hum.CameraOffset:Lerp(targetOffset, 0.2)
end)

UIS.InputBegan:Connect(function(input, gpe)
	if gpe then return end

	if input.KeyCode == Enum.KeyCode.LeftShift then
		sprintInputHeld = true
		if canSprintCheck() then isSprinting = true hum.WalkSpeed = SPRINT_SPEED updateAnims() end
	elseif input.KeyCode == Enum.KeyCode.LeftControl then
		toggleShiftLock(not shiftLockEnabled)
	elseif input.KeyCode == Enum.KeyCode.Q then performDash()
	elseif input.KeyCode == Enum.KeyCode.C then performSlide(false)
	elseif input.KeyCode == Enum.KeyCode.Space and isSliding then performSlideJump() end
end)

UIS.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then 
		sprintInputHeld = false
		stopSprinting() 
		updateAnims() 
	end
end)

local minFallDistance = 3
local lastAirY = nil

hum.StateChanged:Connect(function(_, newState)
	if newState == Enum.HumanoidStateType.Jumping or newState == Enum.HumanoidStateType.Freefall then
		isInAir = true
		muteMovementSounds()
		lastAirY = root.Position.Y

		stopMovementAnims()

	elseif newState == Enum.HumanoidStateType.Landed then
		isInAir = false
		local landedFromHigh = lastAirY and (lastAirY - root.Position.Y) >= minFallDistance
		lastAirY = nil

		if landedFromHigh then
			soundEvent:FireServer("LandingSound")
			landingVfxEvent:FireServer()
			hum.JumpPower = 0
			hum.WalkSpeed = 4
			anims.Land:Play(0.1)

			task.delay(LAND_RECOVERY_TIME, function()
				hum.JumpPower = 50
				hum.WalkSpeed = (sprintQueued or isSprinting) and SPRINT_SPEED or WALK_SPEED
				updateAnims() 
				sprintQueued = false
			end)
		else
			hum.WalkSpeed = (sprintQueued or isSprinting) and SPRINT_SPEED or WALK_SPEED
			updateAnims()
			sprintQueued = false
		end
	end
end)

toggleShiftLock(false)

if UIS.TouchEnabled then
	local mobileGui = Instance.new("ScreenGui")
	mobileGui.Name = "MobileControls"
	mobileGui.ResetOnSpawn = false
	mobileGui.Parent = player:WaitForChild("PlayerGui")

	local function makeButton(text, position)
		local button = Instance.new("TextButton")
		button.Size = UDim2.new(0.1, 0, 0.1, 0)
		button.Position = position
		button.BackgroundColor3 = Color3.fromRGB(25,25,25)
		button.BackgroundTransparency = 0.2
		button.TextColor3 = Color3.new(1,1,1)
		button.TextScaled = true
		button.Text = text
		button.AutoButtonColor = false
		button.Parent = mobileGui

		local corner = Instance.new("UICorner")
		corner.CornerRadius = UDim.new(1,0)
		corner.Parent = button
		button.AnchorPoint = Vector2.new(0.5, 0.5)
		return button
	end

	local sprintBtn = makeButton("SPRINT", UDim2.new(0.8, 0, 0.9, 0))
	local dashBtn   = makeButton("DASH",   UDim2.new(0.65, 0, 0.9, 0))
	local slideBtn  = makeButton("SLIDE",  UDim2.new(0.5, 0, 0.9, 0))
	local lockBtn   = makeButton("LOCK",   UDim2.new(0.9, 0, 0.8, 0))
	local jumpBtn   = makeButton("JUMP",   UDim2.new(0.9, 0, 0.9, 0))

	sprintBtn.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.Touch then
			sprintInputHeld = true
			if canSprintCheck() then
				isSprinting = true
				hum.WalkSpeed = SPRINT_SPEED
				updateAnims()
			end
		end
	end)

	sprintBtn.InputEnded:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.Touch then
			sprintInputHeld = false
			stopSprinting()
			updateAnims()
		end
	end)

	game:GetService("RunService").RenderStepped:Connect(function()
		if sprintInputHeld and not sprintBtn:IsDescendantOf(game) then
			sprintInputHeld = false
			stopSprinting()
			updateAnims()
		end
	end)

	dashBtn.Activated:Connect(function()
		performDash()
	end)

	slideBtn.Activated:Connect(function()
		performSlide(true)
	end)

	lockBtn.Activated:Connect(function()
		toggleShiftLock(not shiftLockEnabled)
	end)


	jumpBtn.Activated:Connect(function()
		if isSliding then
			performSlideJump()
		else
			hum.Jump = true
		end
	end)
end
1 Like

It’s probably the Animate script added at runtime. Run the game, go into workspace and into the character model, then copy the animate script under the player and paste it into player script. Then you can either delete the animations or replace them with your own.

I already had a custom animate script.

just realized i deleted the character WITH the animations, gotta restore a version,

1 Like

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