Animation Sinking Player in Ground

In my combat game i need to disable jumping when the player is attacking because certain combos require holding down space

This has never been a issue until recently where i refactored some code and my player started sinking in the floor.

Ive read that some animations do that but this animation has never done that till now

The character is not being altered in anyway like being anchored which is why this is confusing

Any help?

local players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local ServerStorage = game:GetService("ServerStorage")
local ServerScriptService = game:GetService("ServerScriptService")

local assets = ReplicatedStorage.Assets
local combatAssets = assets.Combat

local EntityManager = require(ServerStorage.Modules.Manager.EntityManager)
local DataManager = require(ServerStorage.Modules.Manager.DataManager)
local weaponSpeedMap = require(ServerStorage.Modules.Combat.weaponSpeedMap)
local GeneralCombatFunctions = require(ServerStorage.Modules.Combat.GeneralCombatFunctions)
local Sprint = require(ServerScriptService.Game.RemoteHandler.Sprint)



local lightAttack = {}
local comboData = {}

local handleAnimation = function(character : Model, animation: Animation, weapon : string, speedMap, holdingSpace) 
	local humanoid = character:FindFirstChildWhichIsA("Humanoid")
	local animator = humanoid:FindFirstChildWhichIsA("Animator")
	local finished = false
	local npc = false
	
	local animationTrack : AnimationTrack = animator:LoadAnimation(animation)
	local swingSpeed = lightAttack.getSpeed(weapon, comboData[character].combo, holdingSpace, character:GetAttribute("Uptilt"))
	print(`Swing speed for weapon {weapon} at combo {comboData[character].combo} is {swingSpeed}`)
	
	animationTrack.Priority = Enum.AnimationPriority.Action
	animationTrack:Play()
	animationTrack:AdjustSpeed(swingSpeed)
	
	GeneralCombatFunctions:HyperArmorCheck(character, animationTrack, false, function()
		-- set finished to true 
		finished = true
		EntityManager:Remove(character, "Attacking")
		
		comboData[character].combo = 1
		comboData[character].debounce = false
	end)
	
	EntityManager:Apply(character, "Attacking")
	
	if players:GetPlayerFromCharacter(character) then 
		npc = false
		Sprint.OnServerEvent(players:GetPlayerFromCharacter(character), "end")
	else
		npc = true
	end
	
	animationTrack.KeyframeReached:Connect(function(keyframe)
		if keyframe == "hit" then 
			-- logic here
		end
		
	end)
	
	local function finishAttack()
		finished = true 
		EntityManager:Remove(character, "Attacking")
		EntityManager:Apply(character, "JumpLocked", 0.6)

		if comboData[character].combo == 5 then 
			comboData[character].combo = 1
			task.delay(1.5, function()
				comboData[character].debounce = false
			end)
		else
			comboData[character].combo += 1
			comboData[character].debounce = false
		end
	end
	
	animationTrack.Stopped:Connect(function()
		if finished then return end 
			
		if speedMap.endlag then 
			task.delay(speedMap.endlag, finishAttack)	
		else
			finishAttack()
		end
	end)
	
	
	
end

function lightAttack.Fire(character: Model, holdingSpace: boolean)
	if not character then
		return
	end

	local npc: boolean?
	local weapon: string?
	local animationName: string?
	local weaponFolder: Folder?

	if not comboData[character] then
		comboData[character] = {
			combo = 1,
			lastTimeSwung = 0,
			debounce = false,
		}	
	end
	if comboData[character].debounce then return end	
	if character:GetAttribute("Equipped") == false then return end
	if EntityManager:CanPerform(character, "Attack") == false then return end
	if players:GetPlayerFromCharacter(character) then npc = false else npc = true end

	if npc == false then
		weapon = DataManager:getWeaponOnCurrentSlot(players:GetPlayerFromCharacter(character))
		weaponFolder = combatAssets:FindFirstChild(weapon)
	else
		weapon = "Fist" -- implementation here
	end

	-- determines the weapon speed at a certain combo
	local speedMap = weaponSpeedMap[weapon]

	if not speedMap then
		warn(`Cannot find speedmap for {weapon}`)
		return
	end

	if os.clock() - comboData[character].lastTimeSwung > (speedMap.resetTime or 1.0) then
		comboData[character].combo = 1
	end

	comboData[character].lastTimeSwung = os.clock()
	comboData[character].debounce = true

	if comboData[character].combo == 4 and holdingSpace then
		animationName = "Attack4a"
	elseif comboData[character].combo == 5 and character:GetAttribute("Uptilt") == true then
		animationName = "Attack5a"
	else
		animationName = "Attack" .. tostring(comboData[character].combo)
	end

	if not weaponFolder then
		warn(`Cannot find weapon folder for {weapon}`)
		comboData[character].debounce = false
		return
	end

	local AnimationInstance = weaponFolder:FindFirstChild(animationName)

	if not AnimationInstance then
		warn(`Cannot find animation {animationName} in {weaponFolder}`)
		comboData[character].debounce = false
		return
	end
	
	handleAnimation(character, AnimationInstance, weapon, speedMap, holdingSpace)

end

function lightAttack.getSpeed(weaponName, combo, holdingSpace, uptilt)
	local speedMap = weaponSpeedMap[weaponName]
	local data = speedMap.speedMap
	
	if (combo == 4 and holdingSpace) or (combo == 5 and uptilt) then 
		return 1.5
	end
	
	if not data then
		warn(`Cannot find speedmap for {weaponName}`)
		return 1.0
	end

	return data[combo] or data.default
end

return lightAttack

Not sure what would cause this, you said you changed some code? In your attack code, are you moving the HumanoidRootPart? Or is your animation affecting the HumanoidRootPart?

No Attack Code is being implemented right now but even if it is nothing is effecting the HumanoidRootPart.

Ive realized now its not the animation because if i dont hold space the character dosnt sink in the floor. Its only when im holding down space.

When i apply the JumpLocked Status its just setting the jumppower to 0 for a extra 0.06 seconds nothing else

This is very strange

So is your jump totally disabled, or only during the attack? And how are you disabling it exactly?

The way we disable is by setting the jumpower to 0

When we add the Attacking Status by doing

	EntityManager:Apply(character, "Attacking")

After we remove the attacking status I also add a extra 0.06 seconds of jump locked which also sets the jumpower to 0

EntityManager:Remove(character, Attacking)

EntityManager:Apply(character, JumpLocked, 0.6)

I wonder if you try setting the jump power to something small, like 1, and see if you still get the sinking. Or maybe try using humanoid setstateenabled