Help with advanced walkspeed managing

I don’t want an entire script or to be carried, but I want to know how I could execute something like this:

I’m making a magic game which involves a lot of walkspeed changes. Sprinting, casting spells, being frozen, etc. These will change your walkspeed.

How would I manage it? For example if I’m sprinting and I am frozen it will reduce my walkspeed, but I want to still be sprinting on the way out. Or If I used a move which increases speed, it carries it after the stun ends. It’s hard to manage it all correctly, any ideas?

I was thinking of a module script but I have no idea what variables to use etc.

Have you tried anchoring the HumanoidRootPart. Coming from a VFX Designer, i completely understand your issue.

Hey maybe try setting up a queue system with a attached priority system.

To explain in better terms, you would have an effect such as being “Frozen” that would render your walk speed to 0. When adding this effect to the queue you would include two other variables, that being a priority and duration. The duration is how long the effect will last and the priority will dictate what it overwrites.

Lets say we had a speed boost with priority level 2 (3 is highest priority, 2 is second highest priority and so forth). This speed boost with priority level of 2 has a duration of 10 seconds and is in the process of being ran through. However a “Frozen” spell hit us, which is a priority of 3, and duration of 5 seconds. As it has a higher priority than other items in the queue it will jump to the front and execute, and then continue execution with the other items in the queue.

Hopefully that makes some sense, I would also to some degree compare this with the “Multi Level Feedback Queue” scheduling algorithm.

This would work with some things, I do that for some of my spells, however I just want the walkspeed to be slower temporarily with some of them.

You would probably want to fire the information to a main walkspeed script that has knowledge of all walkspeed change requests so that you don’t have to search around for walkspeed changes caused by other scripts. This singular script would have the knowledge of all requests and could use logic to determine what, at the time would be necessary to make optimal changes without overlap of two scripts wanting to have different effects.

So essentially, I could create a modulescript that handles every walkspeed request, and call what speed and duration I would need from the script that called it. What might I do to control the speed in this scenario?

You are sprinting and are hit with a freezing attack. Your speed reduces by 50%, and if you stop sprinting you still get hit with 50% of slowness, and if you start, the same, until the freezing goes away. How would I make it keep at 50% if I keep changing my speed?

For example, if I get the old walkspeed when i start my sprint, get frozen half way through my sprint, when I let go i’ll get the old walkspeed [normal speed]
. How could I solve this?

I was thinking having bool values in the player of their effects: frozen, casting, sprinting, etc and have checks every time the walkspeed changes.

if frozen then set half each walkspeed change request

if casting then set walkspeed to 0 and then set back after

if casting and frozen then ensure walkspeed is halved unless freezing ends after

i think it would be best if i had a pre set speed for each thing, so like 12 for speed, 20 for sprinting, etc. and have them change based on your effects so that when you call something it will change to those values