Console Command Problem

Hello,

I tryed to make a simple slowmotion script, it appears that there isn’t any error here, but it justs dosen’t want to execute the command apparently…

Here’s the code :

The commands SlowMoON and SlowMoOFF actually appears in the console, yet it does nothing, what’s the problem ?

Instead of doing 0.02 in the 3rd arg in your first command, Do -0.02 :slight_smile:

What is the point of looping through.

To make the slowmotion smoother, instead of going slowmotion directly.

Also thank you dingusnin.

It’s still doing it all at once
Same effect as just doing it instantly :stuck_out_tongue:

Use **[Math.Approach

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Math.Approach)** to smooth things on a time-based factor. Loops run instantly.

[lua]
local scale = 1;

local function slowmoon()
for i = 1, 2 do
scale = math.Approach(scale, 0.2, 0.05);

      game.ConsoleCommand("host_timescale "..scale.."

");
end;
end;
[/lua]

Somethng like that should work.

Shouldn’t there be a timer? Like, timer.Simple(i/5, function() game.ConsoleCommand("host_timescale “…scale…”
") end) in the loop above. Otherwise it won’t be smooth at all… Unless I’m missing something.