Holding a player in place without using Anchored

I have a situation where the player can hold a key down, and their character is to be pinned in place, even in mid-air. While pinned in place, their character is rotated to face the mouse.hit position.

This works fine right now on the client that does this, but because I am anchoring the HumanoidRootPart to pint hem in place, their character rotation is not being replicated to all clients.

I tried using physics things like AlignPosition but it felt very wobbly.

Does anyone know a good way to achieve what i need?

2 Likes
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0

I mean, you could try welding the character to an anchored part some random place on the map (hence freezing it in place), and enabling Humanoid.PlatformStand, and making walkspeed and jumpheight 0.

2 Likes

You can set the massless to true

1 Like

no that wont work, they will fall, the character is supposed to be suspended in mid-air

1 Like

welding to anchored part makes the thing welded effectively anchored, thus inhibiting the humanoid replication i need.

also, PlatformStad stops all animations too, so thats out. Currently i set the humanoid to Sit = true but this wont keep it pinned in place.

1 Like

will this honestly work? would have to try and set every part of the character to massless, im not sure this will work

1 Like

Just set it to the humanRootPart

2 Likes

this does indeed pin the character the same as doing Anchored but it also has the effect where the character rotation does not replicate to all clients

1 Like

You can use a bodyposition at their current position to simply do this, or use a bodyvelocity with a velocity of like 0.01 to freeze them aswell

2 Likes

Try something like this:

local root
local actualPos = root.CFrame

game.RunService.RenderStepped:Connect(function(step)
    root.CFrame = actualPos
end)
2 Likes

will try, i think i did this at first but im going to try again

1 Like

I wonder if character orientation is only updated when the character moves

1 Like

Didn’t realize, you could set the local gravity property to 0.

Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
workspace.Gravity = 0

You can achieve that for a single local player too, without it affecting the other players server-wide.

2 Likes

this causes very visible character stuttering positions

1 Like

this is worth a try for sure, but then again, setting gravity would have an effect on other things on that client, such as anything relying on physics. I don’t love Roblox physics anyway so I can maybe avoid using it …

EDIT: On second thought, this would not be good. If for example another character ied and their joints were broken, they would not fall. This is just one example that setgin gravity would be less than ideal for this. That said, I tried it and it works flawlessly! I wish setting the HRP to Massless had the same effect.

1 Like

You can use bodyMovers. Such as: BodyVelocity, BodyPosition, etc

1 Like

I set it all up with AlignPosition with all setting to max and its a bit jittery …

1 Like

it turns out the AlignPosition which supersedes BodyPosition works well with these settings: https://i.imgur.com/Cnxcqia.png

1 Like

Now, I don’t know exactly how to make a player freeze in mid air, however a way to disable a player’s controls would be using this code in a LocalScript (maybe in StarterGui?)

local PlayerModule = require(script.Parent:WaitForChild("PlayerModule"))
local Controls = PlayerModule:GetControls()

function disableControls()
	Controls:Disable()
	wait(5) -- or however long you need it to wait before the controls are enabled again
	Controls:Enable()
end

--call the function when needed
2 Likes