Hello, I tried making a vaulting system, I suceeded in detecting WHEN the player should vault but I have some problems on coding the vaulting, I dont know how to make the player actually move through the part the are vaulting to.
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = script.Parent
iswalking = false
local function findPartInFrontTorso()
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Exclude
rayParams.FilterDescendantsInstances = {char}
local origin = char["HumanoidRootPart"].Position
local direction = char["HumanoidRootPart"].CFrame.LookVector
local rayLength = 1
local result = game.Workspace:Raycast(origin, direction * rayLength, rayParams)
if result then
return result.Instance
end
return nil
end
local function findPartInFront()
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Exclude
rayParams.FilterDescendantsInstances = {char}
local origin = (char["Left Leg"].Position + char["Right Leg"].Position)/2
local direction = char["Right Leg"].CFrame.LookVector
local rayLength = 1
local result = game.Workspace:Raycast(origin, direction * rayLength, rayParams)
if result then
return result.Instance
end
return findPartInFrontTorso()
end
UIS.InputBegan:Connect(function(i, g)
if not g and i.KeyCode == Enum.KeyCode.Space and iswalking == true and findPartInFront() then
local part = findPartInFront()
local playerHeadPosition = char:FindFirstChild("Torso").Position.Y
local wallTopPosition = part.Position + part.Size/2
if playerHeadPosition and wallTopPosition then
if playerHeadPosition >= wallTopPosition.Y then
VAULTING CODE HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
end
end
end
end)
UIS.InputBegan:Connect(function(i, g)
if not g and i.KeyCode == Enum.KeyCode.W then
iswalking = true
end
end)
UIS.InputEnded:Connect(function(i, g)
if not g and i.KeyCode == Enum.KeyCode.W then
iswalking = false
end
end)