Garry's Mod Wiki

game.GetTimeScale

  number game.GetTimeScale()

Description

Returns the time scale set with game.SetTimeScale.
If you want to get the value of host_timescale use

local timescale = GetConVar( "host_timescale" ):GetFloat()

Returns

1 number
The time scale

Example

Printing the true timescale.

-- getting the true timescale. local host_timescale = math.Round( GetConVar( "host_timescale" ):GetFloat(), 1 ) -- it will return 1.0000000149012 so we use math.Round local game_timescale = game.GetTimeScale() print( "True Timescale: " .. host_timescale * game_timescale ) -- example of the true timescale if SERVER then RunConsoleCommand( "host_timescale", 0.2 ) -- we cannot use SetFloat on a ConVar not created by Lua. game.SetTimeScale(5) end local host_timescale = math.Round( GetConVar( "host_timescale" ):GetFloat(), 1 ) -- it will return 0.20000000298023 so we use math.Round local game_timescale = game.GetTimeScale() print( "Host_TimeScale: " .. host_timescale ) print( "Game_TimeScale: " .. game_timescale ) print( "True Timescale: " .. host_timescale * game_timescale ) -- should be 1 because 0.2 * 5 is 1.
Output:
True Timescale: 1 Host_TimeScale: 0.2 Game_TimeScale: 5 True Timescale: 1