constant running ? how ?

i guess im just to stupid ?!

local ply = LocalPlayer

function SetSpeed(ply)
	print("should have set the frikkin speed!")
hook.Add("PlayerSpawn", "SetSpeed", SetSpeed)

the hook is called, i get the message, but it just doesnt change my movespeed…
even though this is the accual sample code from

sry to bother with such a newbquestion again…
at this point i need to say some crits about the whole lua documentation, its frikkin hard to learn and nothing to find :frowning:


The default walking speed in Garry’s Mod is 250, and the default run speed is 500. You’ve set both to 250 which is the default walking speed, so you’ll be walking all the time. Try setting both to 500 if you want constant running.

hey, thanks for your reply!

even before, when i pressed shift (+speed) i was running faster, not the same speed…

i changed both the values to 500 but it didnt help, im walking, when pressing shift im running…
the printmsg is called, so it supposed to have triggered…


Local ply = LocalPlayer()

Why is Warsheep rated dumb for this?
It’s right. You define ply as “LocalPlayer”.
Therefore ply is the function, not the actual LocalPlayer. LocalPlayer returns the Local Player Object.
Call ply = LocalPlayer() instead.
or use ply():Setstuf().

Also SetWalkSpeed is serverside afaik. This looks to be called in Client? As LocalPlayer is used.

Serverside so you don’t use LocalPlayer().

yeah, sry…


local ply = LocalPlayer()

was not supposed to be there, thats the accual code i ve got at the moment, and yes its in the /autorun/server folder

function SetSpeed(ply)
	print("should have set the frikkin speed!")
hook.Add("PlayerSpawn", "SetSpeed", SetSpeed)

the message is called, as well the SetStepSize! so i REALLY REALLY dont understand why it wouldnt call the Walk and RunSpeed! >:(


An addon or the Gamemode is changing the speeds after your script is.


i neither have a gamemode nor an addon installed,… pure clean gmod

im not able to test anything now, cause im at work, but you think i should call the function later ? i thought that playerspawn is kinda late?

still seems weird to me, cause the stepsize aint no problem at all…

and again, it cant be that sample code isnt working, how can you learn with it ? i dont wanna spam the forum with these newbquestions, but it really seems that i dont have any other choice

so thanks

It does work… but only you’re doing it right. Is it saying in console “shoul dhave set teh frikkin speed!”?

function SetSpeed(ply)
timer.Simple(1, function(ply)
print(“should have set the frikkin speed!”)
end, ply)
hook.Add(“PlayerSpawn”, “SetSpeed”, SetSpeed)

Does it work?

thanks spencer!
that worked!

but i still dont understand why… ?

why is the StepSize called (or not overwritten, however) and the Speeds aint?
as well the “should have set the frikkin speed!” was printed as well before,…
ok, guess i ll just have to work with this information that its just like this, i ll remember if i get a similar problem again!

thanks a lot guys!


Your hook was being called before the Sandbox Gamemode’s own PlayerSpawn hook, which was setting player speeds to their default value. By adding a timer your code is now going to be ran after sandbox’s own PlayerSpawn hook.

It works because the gamemode sets the walk/run speed after your hook is called :wink:

[editline]8th August 2012[/editline]


ok, thanks!
you guys know what else is set to default in the sandbox gamemode? is there somewhere a list ?

cheers again!

You could always just look at the Sandbox code. A lot of defaults are set.
It’s all just trial and error until you learn more.


/solved :slight_smile: