To do this, I used to use game:GetRemoteBuildMode()
, but recently, I suspect that it has been changed to not report results correctly (it reports false for both sides now). So is there a now a real, non-hackish way to tell if you're running a script from the client or the server?
local RunService = game:GetService("RunService"); if RunService:IsClient() then -- We're on a client woop woop meep meep else -- Poo :c end;
You may run into issues with Studio
To get around it, you can check if the script should be considered local.
local isLocal = RunService:IsStudio() and script:IsDescendantOf(game.Players) or RunService:IsClient();
"Why don't you just check if it's a LocalScript?"
It's from Valkyrie, which uses ModuleScripts inside of the Players. You'll be able to implement your own context-aware check.
If you're using a local script, then it's the client. Anything that local script does will become transferred to the server so everyone else may see what occurred on that client, with the exception of FilteringEnabled which stops the transfer of what a local script does on one client to the server.
A Script will be ran on the server, anything on the server ends up to be transferred to the client. You should know when something is on either client or server, not really sure if there Is a way to check or why one would need to.