TimeModule - Reverse and speed up/slow down time with ease

Note

This module doesn’t let you speed up/slow down time when not in reverse. Please DM me if you know how to do that kind of stuff!

Introduction

Ever wanted to reverse time, or speed it up or even slow it down? This module is for you!

You can get it here: https://www.roblox.com/library/5752328856/TimeModule

Demo

Documentation

TimeModule:Track(BasePart part) -- Track the given object.
TimeModule:Untrack(BasePart part) -- Stop tracking the given object.
TimeModule:SetSpeed(unsigned integer speed) -- Set the speed. Only works when in reverse.
TimeModule:IsReverse() -- Returns whether time is in reverse or not.
TimeModule:Reverse() -- Reverse time.
TimeModule:Unreverse() -- Unreverse time. Note that this doesnt replay all next frames, it lets time go back to normal after a reverse.
TimeModule:Update(float deltaTime) -- Store the current position of all tracked parts.

Here’s an example script that should roughly show you how to use the module:

local runService = game:GetService('RunService')
local players = game:GetService('Players')
local player = players.LocalPlayer
local timeModule = require(script.Parent:WaitForChild('TimeModule'))
local button = script.Parent

local char = player.Character or player.CharacterAdded:Wait()

wait(1) -- wait for the character to spawn in, so we can track it too

for _,v in ipairs(workspace:GetDescendants()) do
	if v:IsA('BasePart') then
		timeModule:Track(v)
	end	
end


button.MouseButton1Down:Connect(function()
	timeModule:Reverse()
	timeModule:SetSpeed(2)
end)

while true do
	timeModule:Update(0.1) -- 0.1 is the delta time(time difference between every update)
    wait(0.1)
end



This will reverse time with twice the speed once the button is clicked.

Contribute

Want to help make this module better? Feel free to make a pull request here:

Fin

I hope you have fun programming with this module! I can’t wait to see the cool stuff you make with it.
Please tell me if you have any suggestions, or if you find bugs. Have a great day.

(sorry if the post is low-quality, i rushed it a bit)

234 Likes

Hello, brokenVectors

This is a great resource for the community!
Could you upload a uncopylocked demo place of it, please?

19 Likes

I feel updating the parts data every frame regardless of if it has moved or not is not the most efficient solution to carry out this task, perhaps look into having a property changed signal for each part’s position which is being tracked, then it may be more practical for people to incorporate into their games.

9 Likes

That’s pretty impressive never seen something like that!

1 Like

Could you add the module’s code on your topic so the people on mobile can easily check it without having to open the Roblox Studio?

Going to experiment with this! I am curious how it would look when I link it with the Death event of a player. This could be interesting :thinking:

2 Likes

Sure! Here it is, as a pastebin:


@LuaBearyGood Great suggestion! I’ll add that as soon as possible. Storing the CFrame of every part every frame is definitely not optimal, I’ll try out something like interpolating between each CFrame.

Edit: Done.


@UltraKing1238 Sure! Here’s the place:

4 Likes

Definitely an idea although I’m not sure how well that’s work when you have a huge array of parts. Creating event listeners for each object could end up being more costly than saving it on a frame basis as there’s very little cost in doing so.

2 Likes

Fixed an issue where timeModule:SetSpeed() would only accept integers, which didn’t allow for slow-mo.

Big thanks to @Lyyrezism for reporting this!

3 Likes

Yep np, reporting is the way improvement is made. xd

1 Like

I used 0.2 as my speed to test it but it froze time instead of slowing it down, I pressed the button as soon as the building started to collapse.
Screenshot_237 Screenshot_238

Also, it glitches and pretty much breaks if you reverse it after you’ve reversed it the first time.

That may be due to networking stuff - try setting the model’s network owner to the player and it should work.

For the 0.2 speed issue, I think it’s some floating point error or something along those lines. I’ll look into it.

Thanks a lot for the bug reports!

(This should help: BasePart | Documentation - Roblox Creator Hub)

1 Like

How do I set the network exactly?

Network Ownership cannot be done on anchored/welded parts.

Hello. I have noticed you on your demo game that your reversal script is ran on a local script.
Not just that but the module script is in the GUI and not ReplicatedStorage.

Do you mind explaining why you are doing this?

#1. Expensive operations like this that need to be framelocked to look right should be on the client, nothing of this workload should be on the server for this reason

#2. Does it matter where he puts the module? It doesn’t matter as long as he requires it. As a matter of fact, if the module isn’t being used by multiple scripts, then it’d make even more sense to put the module just around the area where you need it

3 Likes

This is absolutely amazing. I’ve never seen this before on this platform

1 Like

Just found out you can’t use cars with this D:
Amazing module!

1 Like

I could see some epic puzzle games being made off of this idea in the future!
Edit: Also, does the module track the scale of parts, or just the CFrame?

2 Likes

Just the CFrame - I should probably add functions to let the user choose what properties to track though.
Thanks for the suggestion!


There are a lot of bugs that I forgot to address, I will try my best to fix them ASAP.

1 Like