Ice Slide Puzzle

  • What do you want to achieve?

I want to code an ice sliding puzzle in an area of my map. The movement is free, but when in proximity of the “ice slide puzzle”, the character’s movement is restricted to 4 directions. When a key is pressed, the player moves 4 studs in the direction. When on an ice puzzle, the character moves until it hits a collision, where it can move again. See the video.

  • What is the issue? Include screenshots / videos if possible!

The task is daunting. I have script experience but this seems to combine everything I have learned so far and I am struggling to find resources on how I would accomplish this. Usually, I find similar examples, take them apart and fit them to my purposes, but I have not gotten anywhere with this. I get buggy movement that is unusable, and I am unable to flag when the character’s movement should be limited. Two primary questions:

  1. How could I detect when the player’s movement is limited? When the player is no longer in the ice tile region, how can I turn it off, while assuring that the player doesn’t have free movement in the ice slide region?

  2. How can I detect when the sliding should “stop”?

  • What solutions have you tried so far?
  1. I’ve tried to put an invisible brick with a “.Touched:Connect(” script around the ice slide region, which restricts the character’s movement. However, I do not know how to effectively turn off. Also causes some lag.

  2. I have no idea how to even start with this task. My idea is an if statement, where it inputs the direction the player intends on going, and loops every 4 blocks to see if there’s a collision. Then, outputs a “destination”. However, I don’t know how to stop the movement. I also can’t figure out how I would check to see if there’s a collidable object (like a wall, rock, etc.).

As by forum rules, I don’t intend on having this scripted for me. I learn best with examples and resources. If you know of similar game’s that have their code available that is somewhat similar, that could be helpful as well. Thank you!

This might be a hacky solution but i see no problem with using custom part properties and making the part have 0 friction instead of writing a script to conserve momentum, disable jumping by making JumpHeight 0 on the humanoid. This also handles having to stop since you will be able to move freely once you touch a part that has friction and lets you walk.