Don't seem to be able to print from Script in ServerServices

During a debugging session in Studio I was using print to help me understand what was happening in my data retrieval steps in my scripts (local, ServerScriptService and ServerStortage)
I don’t get anything in the server output for the Scripts in ServerStorage
I have checked that Script does have a print in it but have no idea why there is no output.
I have tried searching in the usual sources (here, google) but nothing helps.
So, if print is not supported in Scripts in ServerStorage what other method do I use to help me find the cause of my problems?

Hi, perhaps you could try moving the scripts to the workspace? Provided you do not have any :getchild stuff in there.

Scripts, just like LocalScripts, will only run if conditions are met. The disabled property must be set to false, and must be a descendant of a place where they’re able to run. All places they can run are listed on both their API pages. In your case, you have the script in ServerStorage. However scripts do not run in ServerStorage.
At this moment in time, scripts only run when they are a descendant of either the workspace or ServerScriptService. You can however, have ModuleScripts in ServerStorage and access them and run them from another script.

2 Likes

This is an old issue, but can easily be bypassed by using a billboard gui with a text label in workspace and placing a pcall output into it.

Ok, thanks for the replies.
Having a second, or is it tenth look, I now see, with my eyes open this time, that the scripts I am on about are all ModuleScripts and the print I am not seeing is when the functions within these scripts are called and do not seem to print out.
I will, using my better eyes, have another look.

ServerStorage is meant for the server to store items. ServerScriptStorage will run scripts. ServerStorage will just store them.

1 Like

So if I have a ModuleScript in ServerStorage that contains a local table and some functions to allow for the manipulation of that table and I require that ModuleScript in a Script in ServerScriptService and then using that call one of those functions it will not return the data requested or modify the table?

Not true ModuleScripts can still run but they aren’t running in ServerStorage they are running off of the script that has requried it. If you simply use require(modulescript) and then fire the function you will end up seeing the print.

Ok, that is what I am now seeing and I now understand where the execution is happening.
I think this item can now be set as solved as the location of the prints is not in ServerStorage.

Alright, just some more info on ModuleScripts for you if you do a while wait() do in a module script and try to require() the module script the require() will yield and maybe end up with an error(Not quite sure) So in a nutshell when you require a module script it executes on the script that has required it.

@iiLemurz_RB

Er, no, how does this help? Moving a script to a different location won’t change the outcome unless you move it to a container where it can’t run. Workspace has been superseded as the canonical location for scripts by ServerScriptService.


@nooneisback

Don’t rely on unsupported hacks, this is bad practice.


@Sartorra

Please don’t do this.

2 Likes

In what way is it an unsupported hack? ServerScripts always could and always will be able to access non-local workspace objects, so why not take advantage of that for testing purposes?

Yes I do realize that you should never doe while wait() but I was explaining to him that if you do it in a module script then when you attempt to require it the script will yield as it is stuck on a loop.

Either I’m misunderstanding what you’ve posted or you’ve posted something off-topic. What exactly are you suggesting?

I’m suggesting taking the pcall’s second returned value (the error message) and setting it to a textlabel’s Text property.

1 Like

It’s not a hack in that case, but I’m confused as to how that resolves the issue. If the script doesn’t run, then this isn’t going to do anything. The best solution here is to diagnose the actual problem and continue from there.

Because it does run, but it isn’t replicated to the client so it’s print outputs aren’t visible. Games that aren’t run in studio have a server output where you can see the messages.

At least, that was the case I last worked on my old framework. Parts did move, but outputs didn’t show.

I’m sorry?

Scripts don’t run in ServerStorage. The exception is a ModuleScript that is required, where the print is issued on the environment that required it.

The script isn’t running.

My bad, did’t see that message.