Sprinting Service
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 . 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!