Currently, I want to make a wall-run system in my game, and I want to make it so that you attach to the part after pressing Space. However, when I run the script, the player moves to the center of Part1 (Part0 is the humanoid root part, Part1 is the target part), and I have no idea how to patch this. I tried setting the C0 to the target part’s CFrame subtracted by the HumanoidRootPart’s CFrame, but the result was the same (and it errored.)
Here is the code.
if pStat.Vaulting then return end
if not end_Input then return end
local ray, side = RaycastLR(5, hrp, false)
local MAX_TIME = 1
---
local function ray_Check()
repeat
ray, side = RaycastLR(5, hrp, false) ----- FIRST RAY CHECK
MAX_TIME -= 0.1
if ray then
break
end
if MAX_TIME <= 0 then
return
end
task.wait(0.1)
until ray
end
------
ray_Check()
if not pStat.Wallrunning then
ray_Check()
if not ray then return end -- failsafe
pStat.Wallrunning = true
----
local instance:Part = ray.Instance
local dist = instance.Position - hrp.Position
---
local new_Weld = Instance.new("Motor6D", hrp)
new_Weld.Name = "Wallrun_Weld"
new_Weld.Part0 = hrp
new_Weld.Part1 = instance
new_Weld.C0 = (hrp.CFrame - instance.CFrame)
else
Cancel_Wall_Run()
pStat.Wallrunning = false
end
Again, I don’t know much math and I’m sorry for my bad wording, but any help is appreciated.