Sword Framework Works but really bad

So I have been scripting this for hours now and I had tried to debug it but nothing seems to work

Problems:

  • Sword is not rotated properly like in the Animation
  • It doesn’t stop the shiftlock and doesn’t make the Custom Mouse Icon pop-up
  • The Player weirdly walks

For References take a loot at this

Results:

Expected:

  • Animation Sword is not rotated properly
  • Shiftlock to be turned off
  • Mouse Icon to change to default and show for the custom one

Code and Explorer:
image

Client Code:

-- // Variables \\ --
local Tool = script.Parent.Parent.Parent.Parent
local Events = Tool:WaitForChild("Events")

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character.Humanoid

-- // For Shiftlock \\ --
local PlayerScripts = Player.PlayerScripts
local Values = PlayerScripts.Values
local IsHoldingTool = Values.IsHoldingTool

-- // Events \\ --
local PLAY_ANIMATION_EVENT = Events.PlayAnimation
local CHANGE_MOUSE_EVENT = Events.ChangeMouse
local SHIFTLOCK_EVENT = Events.Shiftlock

-- // Animation Tracks \\ --
local AnimationsFolder = Tool.Animations
local SWING_ANIMATION = AnimationsFolder.Swing
local HOLD_ANIMATION = AnimationsFolder.Hold

PLAY_ANIMATION_EVENT.OnClientEvent:Connect(function(AnimationName)
	if AnimationName == "Hold" then
		local HOLD_ANIMATION_TRACK = Humanoid:LoadAnimation(HOLD_ANIMATION)
		
		-- Play it bruh lol
		print("working")
		HOLD_ANIMATION_TRACK:Play()
	elseif AnimationName == "Swing" then
		local SWING_ANIMATION_TRACK = Humanoid:LoadAnimation(SWING_ANIMATION)
		local HOLD_ANIMATION_TRACK = Humanoid:LoadAnimation(HOLD_ANIMATION)
		
		-- Play it bruh lol
		print("working")
		HOLD_ANIMATION_TRACK:Stop()
		SWING_ANIMATION_TRACK:Play()
	elseif AnimationName == "StopHold" then
		local HOLD_ANIMATION_TRACK = Humanoid:LoadAnimation(HOLD_ANIMATION)

		-- Play it bruh lol
		print("working")
		HOLD_ANIMATION_TRACK:Stop()
	end
end)

CHANGE_MOUSE_EVENT.OnClientEvent:Connect(function(MouseIcon)
	if MouseIcon == "WeaponMouseIcon" then
		local Player = game.Players.LocalPlayer
		local Mouse = Player:GetMouse()
		local Image = "https://www.roblox.com/library/5986737138/Game-Mouse-Icon"
		Mouse.Icon = Image
	elseif MouseIcon == "DefaultMouseIcon" then
		local Player = game.Players.LocalPlayer
		local Mouse = Player:GetMouse()
		local Image = "rbxassetid://"
		Mouse.Icon = Image
	end
end)

SHIFTLOCK_EVENT.OnClientEvent:Connect(function(Response)
	if Response == "Enable" then
		IsHoldingTool.Value = true
	elseif Response == "Disable" then
		IsHoldingTool.Value = true
	end
end)

Server Code:

-- // Services \\ --

local RunService = game:GetService("RunService")

-- // Variables \\ --

local Tool = script.Parent.Parent.Parent.Parent
local Events = Tool.Events

-- // Events \\ --

local PLAY_ANIMATION_EVENT = Events.PlayAnimation
local CHANGE_MOUSE_EVENT = Events.ChangeMouse
local SHIFTLOCK_EVENT = Events.Shiftlock

-- // Functions \\ --
local function Yield(s)
	local t = tick()
	while tick()-t < s do RunService.Stepped:wait() end
	return tick()-t
end

Tool.Equipped:Connect(function()
	-- Make Motor 6D {first we need the player's character}
	local Character = script.Parent.Parent.Parent.Parent.Parent
	local Player = game.Players:GetPlayerFromCharacter(Character)
	local RightHand = Character.RightHand
	
	-- Creation of Motor6D
	local Motor6D = Instance.new("Motor6D")
	Motor6D.Name = "Motor6D"
	Motor6D.Parent = RightHand
	
	Motor6D.Part0 = RightHand
	Motor6D.Part1 = Tool.SwordHandle
	
	PLAY_ANIMATION_EVENT:FireClient(Player, "Hold")
	CHANGE_MOUSE_EVENT:FireClient(Player, "WeaponMouseIcon")
	SHIFTLOCK_EVENT:FireClient(Player, "Enable")
	
end)

Tool.Unequipped:Connect(function()
	-- Remove Motor6D
	local Player = script.Parent.Parent.Parent.Parent.Parent.Parent
	local Character = Player.Character
	local RightHand = Character.RightHand
	
	-- Removal of MOtor6D
	local Motor6D = RightHand.Motor6D
	
	Motor6D.Part0 = nil
	Motor6D.Part1 = nil
	
	Motor6D:Destroy()
	
	PLAY_ANIMATION_EVENT:FireClient(Player, "StopHold")
	CHANGE_MOUSE_EVENT:FireClient(Player, "DefaultMouseIcon")
	SHIFTLOCK_EVENT:FireClient(Player, "Disable")
	
end)

Tool.Activated:Connect(function()
	-- Set Debounce to true then after a few milliseconds then to false
	local Player = script.Parent.Parent.Parent.Parent.Parent
	local Values = Tool.Values
	local SwordDebounce = Values.SwingDelay
	
	if SwordDebounce == false then
		SwordDebounce = true
		
		PLAY_ANIMATION_EVENT:FireClient(Player, "Swing")
		
		Yield(.5)
		SwordDebounce = false
	end
end)

I need to have a fix for this soon since this is crtical and an major part of my game
Any help is appreciated thanks!