I made a wall run and I made a WeldConstraint to attach the player to the wall but they can move the part. Here’s a video of what’s happening:
If there’s anything wrong with my script that could be affecting this, please let me know.
function Wallrun()
if not LeftWallCheck() and not RightWallCheck() then return end -- needs to go through these casts first.
local Speed = Character:WaitForChild("Humanoid").WalkSpeed
local IsWallRunning = false
local WallRunL = false
local WallRunR = false
local DebounceR = false
local DebounceL = false
local CD = 2.5
if Speed > 20 then -- can't wallrun if no speed
print (Speed)
if LeftWallCheck() then
DebugAttatchment(LeftWallCheck().Position)
local weld = Instance.new("WeldConstraint")
weld.Parent = LeftWallCheck().Instance
weld.Part0 = HRP
weld.Part1 = LeftWallCheck().Instance
Humanoid.AutoRotate = false
local bv = Instance.new("BodyVelocity", HRP)
bv.MaxForce = Vector3.new (9999999,9999999,999999)
bv.Velocity = HRP.CFrame.LookVector * Humanoid.WalkSpeed + -HRP.CFrame.UpVector * 15
task.wait(EndTime)
Humanoid.AutoRotate = true
-- Physics & If they press space they stop Wall Running they Jump off the walL.
-- Their velocity will go down after 3s and End Specific to that person. (EndTime)
-- If they don't press space they keep going.
-- If they are wall running and touch the floor they stop.
-- If they touch the floor they'll stop.
weld:Destroy()
bv:Destroy()
UIS.InputBegan:Connect(function(input, GPE) -- If they stop holding space they'll jump off and end the wall run.
if input.KeyCode == Enum.KeyCode.Space and IsWallRunning then
-- They Jump off and End the Wall Run.
HRP.Velocity = HRP.CFrame.RightVector and HRP.CFrame.UpVector * Speed * 2
IsWallRunning = false
WallRunL = false
end
end)
else
DebugAttatchment(RightWallCheck().Position)
--HRP.Anchored = true -- They cannot move and Face the wall they are against.
Humanoid.AutoRotate = false -- Face Direction they are moving so it doesn't look weird.
task.wait(EndTime)
--HRP.Anchored = false
Humanoid.AutoRotate = true
-- Physics & If they stop Wall Running they Jump off the walL. Play The Anim too.
UIS.InputBegan:Connect(function(input, GPE)
if input.KeyCode == Enum.KeyCode.Space and IsWallRunning then
-- They Jump off and End the Wall Run.
HRP.Velocity = -HRP.CFrame.RightVector and HRP.CFrame.UpVector * Speed * 2
IsWallRunning = false
WallRunR = false
end
end)
end
end
end