Allow us to run a script on both RunContexts

As a Roblox developer, it is currently difficult to efficiently have a launch script run on both the server and all clients

The issue here is pretty obvious, we end up duplicating a script just to have it run on both ends, instead why not have an enum that tells Roblox to load it on both sides with RunContext

The current thing I do is having a single run module under ReplicatedStorage that does the magic there, with two scripts loading it in with this

local ReplicatedStorage = game:GetService("RunService")
require(ReplicatedStorage.Run)

however, it would be easier to have this run module in the script directly with the RunContext of “ServerClient”

If Roblox is able to address this issue, it would improve my development experience because I could write a single launch script and have it run on both contexts

5 Likes

Would be a great feature, as for now, just use module scripts and require it on both server & client.

I actually had a need for exactly this feature recently. I have a LocalScript and Script in player characters to handle connecting custom tools to their hands. LocalScript is for making it look seamless and smooth, and server script is for making it actually work for other players.

I dont think it would be hard to do, considering that Server and Client contexts already exist. Autocomplete is probably where it would get tricky.

1 Like

Well, they could just use what modules use as they can run both on the server and client, which means there are client and server methods revealed. Something better would just be restricting any context specific methods to ensure complete compatibility.

1 Like

This feature request appears to be requesting running the same code on both the server and client

I know that. The code that I described is actually the exact same on the client and server.
(i.e.: script.Parent.ChildAdded:Connect(ConnectTool) and script.Parent.ChildRemoved:Connect(DisconnectTool))

What I meant by “work for other players” is that you can no longer delete stuff from your character, so the RightGrip weld has to be deleted on the server as well (it was previously only getting removed on the client and replicating to the server)