WeldConstraint getting moved while on a Player

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

Is the “part” Anchored?

………………….

1 Like

If you want the player to be attached to the wall, then yeah you can read what mc7oof says about anchoring the part.

But I think it may be better to just make it (without welds) so that the player can’t move beyond a set “range” you define (with it being you can’t move anywhere if you aren’t touching the part).

Hey, the IsWallRunning is set to false but never is updated to true when the wall run starts this could affect the UIS.InputBegan connections. Also, try removing the WeldConstraint and using BodyVelcity or BodyPosition for better control and set the MaxForce high to keep a strong attachment for the player to stay on the wall.

The part is anchored, If it wasn’t It would be moving around regardless if I attached myself to it or not.

1 Like

I was thinking of using an invisible truss part then setting the player’s state to climbing.

I did this while changing their state to Climbing. There’s a couple problems with this method. If they aren’t on a surface they start running on air and It can’t change the direction. It’s shown in the 2 videos below:



I’m thinking of shooting out another ray then getting the part and changing the direction of the body velocity to it. If it detects no part then I’ll end it. I’ll try these out in a bit if I can figure out how to actually do them.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.