Prevent Player from Moving on Z-Axis

I want to prevent the player from moving on the Z-Axis, but I could not find any documentation for the most recent player module update, and I am unsure how to proceed. Basically, I need help with the updated PlayerModule. I have looked for posts relating to this, but none have solved my issue.

local HRP = script.Parent:FindFirstChild("HumanoidRootPart")
local Zpos = 0
local Force = Instance.new("BodyPosition")
Force.Name = "Stay on Z position"
Force.Parent = HRP
Force.P = 9999999999999
Force.Position = Vector3.new(0,0,Zpos)
Force.MaxForce = Vector3.new(0,0,99999)

This creates a Body Position that locks you on the Z position (Zpos) you provide, as long as you don’t spawn too far from that Z position it should work fine!
robloxapp-20221126-1221478.wmv (3.9 MB)
Edit: If it wasn’t obvious, you have to put it in StarterCharacterScripts. It also works with NPCs if you put it in the NPC’s model

Another solution without relying on physics could be this

I figured out how to do it, all I needed to do was to create a PlaneConstraint under the Player’s HumanoidRootPart. I set the Attachment0 to an attachment under baseplate (it worked with anything), and Attachment1 was set to HumanoidRootPart.RootRigAttachment. I hope this helps anyone looking for the answer. If you have any questions let me know.

8 Likes

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