Sprinting Service, create sprinting with minimal scripting(actually good, with mobile, PC, and Xbox support)

Sprinting Service

source code :floppy_disk: download :arrow_down:

Introduction

so, for the longest time now, I’ve seen so many low quality sprinting recourses. Where it’s impossible to get a system that actually works on all 3 devices(mobile, pc, xbox), while maintaining quality and customizability. So I waited, waited more, and waited even more. So, I decided that i’d make my own, that was customizable, decent, and compatible on ALL devices. Now, you may be wondering, these modules/scripts do the job, why should I use this compared to the others?
Well, here’s the benefits of using a system like this

  • customizability those systems I listed above(and much more), lack the ability for customization, using sprinting service, you can change keys, add mobile buttons, custom mobile buttons, mobile button icons, customize keys, and much more! The sky is the limit using this module.

  • prevents false positives, many other sprinting modules/scripts are down for false positives, for example, if a player is typing in chat and they say the letter, it’ll fire the sprint, which is annoying. Especially in competitive games where you have a certain amount of stamina, it can get annoying very quickly. Well, sprinting service completely destroys this possibility by using Context Action Service.

  • compatibility Unlike many sprinting modules/scripts, this module works on Xbox, PC, and Mobile. You might be wondering, why should I care about this? Well, if you have a feature that only works on one device, it can be annoying for those who dont play on such device. Which means that those players could leave which means you lose money :money_with_wings: . Also, considering 55% of roblox users are on mobile, so if a feature only works on PC, you’ll be losing out on 55% of roblox users(which is bad).

there are many other reasons on why you should use this, but those are the main 3 in my opinion.

examples

Here are some simple stuff I made using the module, you can do various stuff using this module

Mobile

default mobile button:

custom Ui:

PC:

On PC

adding into game

installation

First, get the module here, once installed, move it into replicated storage. This is when we can start to script

scripting the sprint

First, insert a local script into starter player scripts. Then type this out

local module = require(game.ReplicatedStorage:WaitForChild("SprintModule"))
local sprint_data = module.new() -- creates our sprinting data
sprint_data:Init("sprint") -- initialize for it to start being used, sprint is the id of the sprint data, this is required. 

There you go! You now have a functional sprint that works on PC, mobile, and Xbox in your game with 3 lines of code! Of course, this is very basic. Well, we can customize our sprint to make it unique and fit with the style of the game! The next section below will show you how to customize it!

customization

Now, we have a simple sprint, but this is VERY VERY basic. So we can customize the sprint data so it wont be basic. Here are all the things you can customize inside sprint data at the current moment


MOBILE CUSTOMIZATION

  • mobile_button_icon: The icon for the mobile button, by default, this will be a simple icon, you can edit this.

  • mobile_button_title: the title of the mobile button, by default this is nil. This is a string value. If set, it’ll override the icon.

  • phone_button_offset: the offset of the mobile button on phones. By default, this will be set to 45. This value is a float.

  • tablet_button_offset: the offset of the mobile button on tablets. By default, this will be set to 2.45. This value is a float.

  • uses_default_ui: if the mobile ui uses the default sprint ui. By default, this is set to true. If value is false, there will be no mobile button. This property is intended for custom mobile button ui.

  • sprint_ui: if the mobile ui uses a custom gui. This must include the path of the ui from playergui. Currently, it only supports Text Buttons and Image Buttons. uses_default_ui must be set to false for it to work as intended.


SPRINT BEHAVIOUR


  • default_speed: the speed that the player has when they stop sprinting. By default, this will be the place’s default walkspeed.

  • run_speed: the speed that the player has when they start sprinting. By default, this will be default_speed's value multiplied by 2.


FOV


  • use_run_FOV: If the player’s FOV changes when they start sprinting/stop sprinting. By default, this is set to true. If set to false, the player’s FOV will not change. This is a bool.

  • running_FOV: The player’s FOV when they start to sprint. By default this is set to 85.

  • default_FOV: The player’s FOV when they stop sprinting. By default, this is set to 70.

  • FOV_tween_speed: how long the FOV tween takes.

  • FOV_tween_style: the easing style of the FOV tween. By default, this is set to Quad.

  • FOV_tween_direction: The easing direction of the FOV tween. By default, this is set to Out

  • FOV_tween_info: Returns the Tween Info of the FOV tween.


Events


  • Sprinted: Fires whenever the player starts to sprint. Returns the time of which the player started to sprint in Epoch Time.
  • Unsprinted: Fires whenever the player stops sprinting. Returns the time of which the player stopped sprinting in Epoch Time. Also returns how long the player was sprinting for.

Other


  • valid_keys: the keys that can be used to activate the sprint. This is a table, by default, it is: PC: Right Shift, Left Shift, Xbox: ButtonX

Examples

here are some examples on how to customize it

Custom Ui:

-- custom ui
local module = require(game.ReplicatedStorage:WaitForChild("SprintModule"))
local sprint_data = module.new() -- creates our sprinting data
sprint_data.uses_default_ui = false -- makes it so the ui doesn't pop up
sprint_data.sprint_ui = game.Players.LocalPlayer.PlayerGui:WaitForChild("Ui"):WaitForChild("TextButton") -- the button 
sprint_data:Init("sprint") -- initialize AFTER you customize, there is a chance of it being buggy if you initialize then start editing 

Sprinted and Unsprinted

-- sprint and unsprinted
local module = require(game.ReplicatedStorage:WaitForChild("SprintModule"))
local sprint_data = module.new() -- creates our sprinting data
sprint_data.Sprinted:Connect(function(start_time)
	print(string.format("player started to sprint at %.2f", start_time))
end)
sprint_data.Unsprinted:Connect(function(stop_time, time_in_sprint)
	print(string.format("player stopped sprinting at %.2f and was sprinting for %.2f", stop_time, time_in_sprint))
end)
sprint_data:Init("sprint") -- initialize AFTER you customize, there is a chance of it being buggy if you initialize then start editing 

outro

Well, thank you for reading all the way! I hope this module could help you out! I can’t wait to see what people can come up with this module! If you have any feedback, or come across any bugs then feel free to say down bellow! Peace!

26 Likes

This is a well-made sprinting module, nice work!

I believe you missed the point of my two posts about sprinting. They were to introduce the concept of “building up” the sprinting effects, not provide a cross-platform sprinting solution like this.

An improvement I can suggest for this is also tweening the Walk animation’s playback speed to match the WalkSpeed. This is important since if they aren’t in sync, it will ruin the sprinting experience.

thank you for the feedback! That must’ve been a misconception on my part. I apologize.
i’ll think about doing this. Thanks for the feedback!

1 Like

Hi, how can I add a custom animation for when the player is sprinting? and does it work with R6?

you’ll need to fork the default animation local script inside the player’s character to check if the player is running. It’s easy if u know what your doing. Custom run animations are in the works at the moment. It should be done within a few days.

Yes it does

1 Like

can you attach a video of this happening? Also can you send me your script of this in dms?

I appreciate your efforts into this, but perhaps add a setting where you can set a run animation?

thank you

this is in the works. If you look at the source code, you can already see that there’s a property for run animation(just doesn’t work yet). It’s almost done :hugs:

1 Like

hey! sorry for the necropost, but is there a way to tween the walking/running speed as well? for example when I press shift it takes about 1 second to get to full run speed and vice versa?

The creators is banned from the devforum right now, youl have to ask someone else.

wait really? what happened?

charlimit

I don’t know, it just says he was suspended, and he hasn’t been online for 3 weeks.

I put an animation setting but the problem is whenever you’re
idle and pressed shift, the animation will play so, I don’t have any
idea how to fix that. Hope someone can.

here’s the updated Module:
https://www.roblox.com/library/9226119927/SprintModule-With-animation

Hope this helped!

1 Like

It’s not cool to call others out just because you think their work is not as good as yours.

5 Likes

image
That’s not right to just link to other people’s resources and call it “low quality”, you should specifically mention what’s good about your sprinting service, and then point out common flaws with other sprinting scripts, but it’s just not cool to call other people out like that

6 Likes