Help with MoveDirection

I made a GUIButton that toggles the player to swim as if they were in water, but when I am swimming mid air and let go of all movement keys, the player still moves as if it were sliding on ice.

I’m trying to write a localscript that detects the MoveDirection in the localplayer’s humanoid object and anchors the HumanoidRootPart if the button is activated and the player is not moving, but unanchors it when the MoveDirection is anything other than “0,0,0” here is that script below (I corrected the spelling error in line 4):
image

Here is the script to make the player swim (it works as intended other than above issue):
image

this is a demonstration of the issue:
robloxapp-20220625-0102599.wmv (1.3 MB)

Do you get an error in the Output window?

Changing Ancored to Anchored in line 5 of the top script might help.

I corrected the spelling mistake in the top script, as well as removed “Character” and now it just anchors HumanoidRootPart when I click it rather than only when the text says “Swim: ON” and the MoveDirection is 0,0,0

1 Like

Instead of comparing Vectors you can compare the magnitude of the MoveVector

if player.Character.Humanoid.MoveDirection.Magnitude > 0 then

I added that line to my code and i get this error:
image

Well there is your problem … you don’t exists :rofl:
Take the .Name off the end of the 1st line after LocalPlayer

that seems to get rid of the error but the script still doesnt seem to work

Seems to be Anchored no matter the outcome … both are true. The 1st one should be false.

1 Like