My code sets toggles PlatformStand successfully, the problem with it is that it glitches the character. Is it my code or Roblox?
I have a spectator system and I wanna disable the movement for the player when in spectator mode. Is this possible?
Code:
local player = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local open = false
script.Parent.MouseButton1Click:Connect(function()
if open == false then
open = true
script.Parent.Parent.SpectatingFrame.Visible=true
game.Players.LocalPlayer.Character.Humanoid.PlatformStand=true
else
if open == true then
open = false
game.Players.LocalPlayer.Character.Humanoid.PlatformStand=true
script.Parent.Parent.SpectatingFrame.Visible=false
camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end
end
end)
Snapshot I took:
1 Like
This isn’t a glitch, it’s just how PlatformStand
works, since collisions for the legs are disabled during it (and during most humanoid states, it uses HipHeight to stand). If you want to prevent the player from moving, there’s a few methods:
Method 1: WalkSpeed / JumpHeight (or JumpPower):
You’d want to set the Humanoid’s WalkSpeed and JumpHeight/JumpPower to 0, which prevents movement entirely. This method is useful because it allows the character to still be affected by physics, but prevents them from moving.
However, this does have a downside, since the client can simply set these manually since they’re managed from the client (and you’d have to reset the speed manually).
Method 2: Anchoring
This method is basically the same as the first, Except it entirely prevents the player from moving, even when affected by physics. The difference with this one is that it preserves the Humanoid’s WalkSpeed and JumpPower, which can be annoying to reset.
The issues are that it makes the character entirely immovable even by physics, and can also be undone by the client again (since they have network ownership over their own client)
3 Likes
Does walkspeed and jump height reset when the player resets?
I think I’ll change the walkspeed and jump height. Both of those are located in the humanoid right?
1 Like
Worked well for me, thank you!
(WalkSpeed is in the humanoid btw for anyone wondering)
1 Like