Running fucntions on server startup


#1

I have some functions that i want to run one time once the server is started up. I have placed these function inside a server script, but they don’t run. Perhaps they try to run before the parts they are affecting have lodaded in?

Id there any way to test if the server is loaded before running scripts and functions?

I have tried this:

if not game.IsLoaded then
    game.Loaded:Wait()
	obbyTools.setup() -- setup the obby stuff, NOT WORKING
end

Thanks!


#3

I don’t think you need to wait for the server to load and these should only be used in a LocalScript although I could be wrong. I’m pretty sure they are not needed in a server sided script though.

Edit: Only works in a LocalScript!
Evidence


#4

If it is on the server, try just executing the code without the bounds of a function.

Inside your script:

obbyTools:Setup()


#5

As per the wiki the game.Loaded is a client sided event for when the game is first loaded for the client.

As you said this is a server script it is safe to assume the server is already loaded by the time a server script runs.


#6

Thanks all, I changed the order of things and just put the function call outside of a function in a server script and it ran fine. Thanks again!