Script not firing in ServerStorage

Hello,
So I added a server script in ServerStorage, but the script is not firing. I know because the first line is print('test') but there is no output. Is this intentional?

I don’t believe you can fire scripts in ServerStorage. ServerScripts only work in Workspace or ServerScriptService

1 Like

Okay, thank you. I have a question though:
I’m making a tycoon game where the unbought stuff is in ServerStorage, as well as the buttons, which have scripts in them. Is there a way that I can make the scripts fire while still being in ServerStorage or do I have to parent them to something else?

You can if you set the script’s RunContext to Server. This allows it to be basically ran anywhere in the DataModel.

1 Like

Thank you so much. I have been trying to find out why my scripts have not been working, but I never considered the RunContext (mostly because I didn’t know what the difference from Legacy was to Server or Client)

Legacy refers to the conditions needed to make a script run prior to this property being added. Scripts were only allowed to be ran if they were a descendant of workspace or ServerScriptService. By default, the RunContext of a script is set to Legacy, so you can still see this behavior even now. I suppose it’s to maintain games that are no longer updated by their developers – where scripts may be located outside of those 2 containers (workspace and ServerScriptService) but parented to them later through another script. Server and Client should be obvious enough. If you set the RunContext to Server, the script will be ran anywhere in the DataModel on the server. If you set the RunContext to Client, the script will be ran anywhere – the rule being that the container is also replicated to the client (which excludes ServerStorage and ServerScriptService) – in the DataModel on the client.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.