i have this script, i want to make a ledge grab like this http://gyazo.com/e6164b29f1c573a5b1112d24b68f1bec?fbclid=IwAR16Rb22_rFS7juXKd0pkgU_uE8CAQ5oal2OxI4snMdzdrGGyqjs_mZn9IQ
wait()
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local plr = Players.LocalPlayer
local plrGui = plr:WaitForChild("PlayerGui")
repeat wait() until plr.Character and plr.Character:FindFirstChild("Humanoid")
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local torso = char:WaitForChild("HumanoidRootPart")
local head = char:WaitForChild("Head")
local Stats = plr:WaitForChild("PlrStats"):WaitForChild("Stats")
local Stamina = Stats:WaitForChild("Stamina")
local debounce = false
local StrightJumpAnimation = humanoid:LoadAnimation(script:WaitForChild("StraightJump"))
local RightJumpAnimation = humanoid:LoadAnimation(script:WaitForChild("RightJump"))
local LeftJumpAnimation = humanoid:LoadAnimation(script:WaitForChild("LeftJump"))
local maxDistance = 4.5
local canDoWallJumps = true
local rayFunctions = {
function()
local frontRay = Ray.new(torso.Position, torso.CFrame.lookVector*10,-torso.CFrame.rightVector*10,torso.CFrame.rightVector*10)
return "Front",frontRay
end;
}
local function WallJump()
canDoWallJumps = false
local distance, sideName = math.huge, ""
local normalRay
for i = 1, #rayFunctions do
local name, ray = rayFunctions[i]()
local hit, position, normal = workspace:FindPartOnRay(ray, char)
local mag = (position-torso.Position).Magnitude
if((mag < distance)and(hit)and((not hit:IsA("BasePart"))or(hit.CanCollide)))then
distance = mag
sideName = name
normalRay = normal
end
end
if distance <= maxDistance then
if sideName == "Front" then
LeftJumpAnimation:Play()
local Root = plr.Character:WaitForChild("HumanoidRootPart")
local Bodv = Instance.new("BodyVelocity")
Bodv.MaxForce = Vector3.new(90000,90000,90000)
Bodv.Velocity = Root.CFrame.lookVector * 0 + Vector3.new(0,0,0)
Bodv.Parent = Root
wait(0.2)
local Position = char.HumanoidRootPart.CFrame.lookVector * -35 + Vector3.new(0,55,0)
wait(0.05)
Bodv:Destroy()
wait()
StrightJumpAnimation:Play()
local Bodv1 = Instance.new("BodyVelocity")
Bodv1.MaxForce = Vector3.new(90000,90000,90000)
Bodv1.Velocity = Position
Bodv1.Parent = Root
game.Debris:AddItem(Bodv1,0.1)
wait(0.1)
debounce = false
elseif sideName == "Ledge" then
print("HGeae")
LeftJumpAnimation:Play()
local Root = plr.Character:WaitForChild("HumanoidRootPart")
local Bodv = Instance.new("BodyVelocity")
Bodv.MaxForce = Vector3.new(90000,90000,90000)
Bodv.Velocity = Root.CFrame.lookVector * 0 + Vector3.new(0,0,0)
Bodv.Parent = Root
wait(0.2)
local Position = char.HumanoidRootPart.CFrame.lookVector * -35 + Vector3.new(0,55,0)
wait(0.05)
Bodv:Destroy()
wait()
StrightJumpAnimation:Play()
local Bodv1 = Instance.new("BodyVelocity")
Bodv1.MaxForce = Vector3.new(90000,90000,90000)
Bodv1.Velocity = char.HumanoidRootPart.CFrame.lookVector * 0 + Vector3.new(0,75,0)
Bodv1.Parent = Root
game.Debris:AddItem(Bodv1,0.1)
wait(0.1)
debounce = false
end
end
wait(0.1)
canDoWallJumps = true
end
if (UIS.KeyboardEnabled) then
UIS.InputBegan:Connect(function(inputObject, GPE)
if ((not GPE) and (inputObject.KeyCode == Enum.KeyCode.Space) and (humanoid:GetState() == Enum.HumanoidStateType.Freefall) and (canDoWallJumps)) then
WallJump()
end
end)
else
plrGui:WaitForChild("TouchGui"):WaitForChild("TouchControlFrame"):WaitForChild("JumpButton").InputBegan:connect(function(inputObject)
if (humanoid:GetState() == Enum.HumanoidStateType.Freefall) and (canDoWallJumps) then
WallJump()
end
end)
end
