Hey, so I was wondering how to disable player movement on the z axis. I tried this video but it was outdated
Hey, so I was wondering how to disable player movement on the z axis. I tried this video but it was outdated
maybe try using the line runner code (from the game template roblox gives you as an option for using to build with)
might be useful since roblox will update the code.
that code doesn’t seem to be working
I faced this problem a while ago. My solution was to use a BodyPosition object. It applies a force of math.huge
on the Z axis without damping (hence bodyPosition.D = 0
). The following code forces the HumanoidRootPart to a Z position of 0.
function lockZAxis()
local bodyPosition = Instance.new("BodyPosition")
bodyPosition.MaxForce = Vector3.new(0, 0, math.huge)
bodyPosition.Position = Vector3.new()
bodyPosition.D = 0
bodyPosition.Parent = humanoidRootPart
end
Thanks for the help! I will use this in my game!
Also, how would I put it back to normal?
If by normal you mean no restricted axis, then you can either destroy the BodyPosition or set its
MaxForce property to Vector3.new()
(which is equal to Vector3.new(0, 0, 0)
).