Change movement from player to part

I’m currently making a Harry Potter inspired game, right now I’m creating the Wingardium Leviosa spell.

The way I want it to work is after you hit a part with the spell, your movement would be disabled and you’d instead be able to control the part with your movement keys.

The way I did this was by using the PlayerModule:GetControlModule().
I used ControlModule:Disable() to disable the characters movement, and then sent the ControlModule:GetMoveVector() (rotated to match the camera) to a RemoteEvent where the server would then move the part.

Problem is, doing ControlModule:Disable() also disables ControlModule:GetMoveVector().

I tried looking at other ways of disabling the player’s movement, but I didn’t really like any of them.
Anchoring the player’s HumanoidRootPart would cause the player to stay in the air if they were jumping, setting the player’s WalkSpeed to 0 might break some of my other scripts, and unbinding the movement keys also disables ControlModule:GetMoveVector().

I’m wondering if there are any other ways of disabling the player’s movement, or if there is a better way of doing what I’m trying to.
Also I tested the rest of my code without disabling movement and everything worked fine, so there isn’t another issue causing this.

There are two options that come to my mind:

  1. lazy approach
    When player starts controlling the part, set his walkspeed and jump power to zero
  2. smart but easy approach
    Make your own move vector function
    It really shoudn’t be complicated, although I haven’t tested it, just create vector3 depending on player’s current input (If player holds “W” button make it like vector3.new(5,0,0)) and then just multiply this vector with camera lookVector

Thanks for the reply! I did originally say I didn’t want to use walkspeed cause it might break some other scripts, but as long as I build those scripts around it they should be fine.

Also with your other idea, that could probably work although it would be hard to make the script support other platforms other than pc, but tbh I haven’t really made my other scripts to be non pc compatible so it probably wouldn’t matter anyway.

I’ll probably end up using one of your ideas, but I will keep the topic open for a bit longer to see if there are any other suggestions.

PlatformStand?, and maybe also autoRotate to false then?

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