Attempt of making a Pole Swing Script

Hello Everyone, I’m attempting to make a Pole Swing like in Prince of Persia, Sonic, etc.
So far this is what I could do, I’ve read a few posts, but there’s not much information about this though.
Basically I’m using a “Hitbox” part and make the player hold it’s ledge to replicate…
But this isn’t what I’m trying to achieve though

I’ll leave my script and a video to showcase what I’ve done so far…
If anyone could give me some information, or some tips, I would very much appreciate that !

local plr = game.Players.LocalPlayer
local Character = plr.Character or plr.CharacterAdded:Wait()
local Root = Character:WaitForChild("HumanoidRootPart")
local Head = Character:WaitForChild("Head")
local Hum = Character:WaitForChild("Humanoid")
local CA = Hum:LoadAnimation(script:WaitForChild("ClimbAnim"))
local HA = Hum:LoadAnimation(script:WaitForChild("HoldAnim"))
local UIS = game:GetService("UserInputService")
local CS = game:GetService("CollectionService")
local RS = game:GetService("RunService")

local function isLedge(part)
	return part and CS:HasTag(part, "Swing")
end

local ledgeavailable = true
local holding = false

local function climb()
	local Vele = Instance.new("BodyVelocity", Root)
	Root.Anchored = false
	Vele.MaxForce = Vector3.new(1,1,1) * math.huge
	Vele.Velocity = Root.CFrame.LookVector * 30 + Vector3.new(0, 5, 0)

	HA:Stop()
	CA:Play()

	game.Debris:AddItem(Vele, 0.15)
	holding = false

	wait(0.75)
	ledgeavailable = true
	Hum.AutoRotate = true
end

local function release()
	if not holding then return end

	Root.Anchored = false
	local Vele = Instance.new("BodyVelocity", Root)
	Vele.MaxForce = Vector3.new(1,1,1) * math.huge
	Vele.Velocity = Vector3.new(0, -20, 0)

	HA:Stop()
	CA:Stop()

	game.Debris:AddItem(Vele, 0.2)
	holding = false

	wait(0.5)
	ledgeavailable = true
	Hum.AutoRotate = true
end

RS.Heartbeat:Connect(function()
	local r = Ray.new(Head.CFrame.p, Head.CFrame.LookVector * 5)
	local part, position = workspace:FindPartOnRay(r, Character)

	if part and isLedge(part) and ledgeavailable and not holding then
		if part.Size.Y >= 7 then
			if Head.Position.Y >= (part.Position.Y + (part.Size.Y / 2)) - 1 
				and Head.Position.Y <= part.Position.Y + (part.Size.Y / 2) 
				and Hum.FloorMaterial == Enum.Material.Air 
				and Root.Velocity.Y <= 0 then

				Root.Anchored = true 
				holding = true 
				HA:Play() 
				ledgeavailable = false
				Hum.AutoRotate = false
			end
		end
	end
end)

UIS.InputBegan:Connect(function(Key, Chat)
	if not holding then return end 
	if Key.KeyCode == Enum.KeyCode.W or Key.KeyCode == Enum.KeyCode.Space and not Chat then
		climb()
	elseif Key.KeyCode == Enum.KeyCode.S then
		release()	
	end
end)

Wrong category.

Please put this in: #resources