How can i incorporate 2 modules together?

Hello, I have 2 modules, a movement handler and a sprint handler which are both open-sourced modules. I wish to incorporate both into each other so they can work together and not have conflicts between the two, but I’m struggling.
The resources in question are Sprinting Service and Movement Handler

These 2 modules both have a sprinting and sliding functionality, the only difference is that Movement handler comes with sliding and Sprinting Service comes with full-fledged mobile/console support, and i wanna incorporate sprinting service’s sprinting into Movement Handler so it can have the cool slide with Sprinting Service’s smooth sprinting and support. How can i achieve this?

Both modules can be found on their topics, posting the code here would be too long.
Thank you in advance

2 Likes

There’s generally no easy way to do that. You’ll have to make a 3rd module that incorporates the features you want from the two existing modules. Fortunately it’s not too much code, so it shouldn’t be especially hard. If there’s anything specific you’re stuck on feel free to ask

2 Likes

my main issue here is trying to stop both modules from having conflicts, i tested them out while they were both active and a lot of bugs arose, such as sliding being unusable, crouching/proning (???) not changing speed, and other stuff. How can i go about creaing this third module? i don’t have many experiences WITH modules, so i need some sort of general idea :sweat_smile:

1 Like

I’d start with the MovementHandler as a base and add features from sprinting-service, because at a quick glance MovementHandler seems to be quite a bit higher quality. Look at MovementHandler to see why it doesn’t support mobile/console controls, and change it so that it does

1 Like

i understand where you’re coming from, and i somewhat understand what i have to do, but as i mentioned, i have very little experience with modules, are there certain procedures i need to follow? or do they function like normal scripts?

1 Like

It’s best to just read up on the wiki. Basically yeah modules are exactly like scripts, except they only run once per context when they’re required by a player or the server, and must return exactly one value (usually a table with data and functions).

1 Like

i’ll check the developer hub and attempt to make a module that does what you suggested, i’ll update you if anything happens. thank you

1 Like

Just paste one’s code into the other?
I’m pretty confused by the question. That probably isn’t the answer, just tell me exactly what you want.

-- load both modules into global variable this can be done anywhere in any script (you only need to do it once)
_G.module1 = require(game.ServerStorage.Module1)
_G.module2 = require(game.ServerStorage.Module2)
-- inside module1 you can use module2 like this
_G.module2.Function("Hello")
-- inside module2 you can use module1 like this
_G.module1.Function("World")