My vault script is not working

Hi, so my vault ability script isn’t working I’m trying to make a vault script for a parkour game but It’s not working the script is in ‘StarterCharacterScripts’ as a localscript
here’s the script

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local HRP = char:WaitForChild("HumanoidRootPart")
local Hum = char:WaitForChild("Humanoid")
local CA = Hum:LoadAnimation(script:WaitForChild("ClimbAnim"))

local vaultavail = true

while game:GetService("RunService").RenderStepped:Wait() do
	local r = Ray.new(HRP.Position, HRP.CFrame.LookVector * 7 + HRP.CFrame.UpVector * -5)
	local part = workspace:FindPartOnRay(r,char)

	if part and ledgeavail then
		if part.Name == "Vault" then
			if Hum.FloorMaterial ~= Enum.Material.Air then
				vaultavail = false
				local Vel = Instance.new("BodyVelocity")
				Vel.Parent = HRP
				Vel.Velocity = Vector3.new(0,0,0)
				Vel.MaxForce = Vector3.new(1,1,1) * math.huge
				Vel.Velocity = HRP.CFrame.LookVector * 20 + Vector3.new(0,30,0)
				CA:Play()
				game.Debris:AddItem(Vel, .15)
				wait(0.75)
				vaultavail = true
			end
		end
	end
end
1 Like

Nevermind everybody i found the problem is should have been




local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local HRP = char:WaitForChild("HumanoidRootPart")
local Hum = char:WaitForChild("Humanoid")
local CA = Hum:LoadAnimation(script:WaitForChild("ClimbAnim"))

local vaultavail = true

while game:GetService("RunService").RenderStepped:Wait() do
    local r = Ray.new(HRP.Position, HRP.CFrame.LookVector * 7 + HRP.CFrame.UpVector * -5)
    local part = workspace:FindPartOnRay(r,char)
    
    if part and vaultavail then
        if part.Name == "Vault" then
            if Hum.FloorMaterial ~= Enum.Material.Air then
                vaultavail = false
                local Vel = Instance.new("BodyVelocity")
                Vel.Parent = HRP
                Vel.Velocity = Vector3.new(0,0,0)
                Vel.MaxForce = Vector3.new(1,1,1) * math.huge
                Vel.Velocity = HRP.CFrame.LookVector * 20 + Vector3.new(0,30,0)
                CA:Play()
                game.Debris:AddItem(Vel, .15)
                wait(0.75)
                vaultavail = true
            end
        end
    end
end
1 Like