Roblox Plugin Help

Hello, I’m making a plugin and when I click play, it runs on the client and the server. Is there any way to make it just run on the server? Thanks, i’ve looked everywhere for a solution.

Just add a restrictive overlay if not on Server.

1 Like

check if its client at the beginning of the script, and if it is then stop the rest of the script

if (game:GetService("RunService"):IsClient()) then return end
1 Like

plugins always run on the ‘server’
(quotes because they only run in studio, they don’t run when you are in a published version of your game).

literally in the first sentence of the documentation they state that.

Plugin is the main object responsible for creating basic studio widgets. It is a custom add-on to Studio which adds new behavior and features that are not normally included.

source: Plugin | Documentation - Roblox Creator Hub

now if you want a script to only run on the server, you can do this:

local runservice = game:GetService("RunService")--access required functions

if runservice:IsClient() then return end--stop executing when we are on the client

similarly you can also block execution on the server, or in studio:

if runservice:IsServer() then return end
--and studio
if runservice:IsStudio() then return end

Runservice contains more methods for checking certain things, so you can read the documentation on it if you want:
RunService | Documentation - Roblox Creator Hub

hope this helps!

1 Like

Ahh alright thanks, I’ll give it a go now.

Ok thanks so much, I will mark this as the solution, however I was wondering if you could help me with another issue. It’s saying ‘attempt to call a nil value’ on the line which i’m using loadstring()!

Thanks for your response as well. I appreciate the response.

1 Like

You haven’t provided any code. So I can’t see which line uses loadstring(), however, don’t use loadstring, it is heavy function and it really isn’t recommended.

but attempt to call a nil value usually occurs on a line that resolves like so; nil().
so, obviously loadstring isn’t nil, but any function in the string passed to loadstring might be nil.
consider checking your string.

also, it is worth noting, that loadstring is disabled and doesn’t work unless re enabled.

Loads Lua code from a string and returns it as a function.
Unlike standard Lua 5.1, Roblox’s Lua cannot load the binary version of Lua using loadstring().
loadstring() is disabled by default. For guidance around enabling it, see ServerScriptService.

source: Lua Globals | Documentation - Roblox Creator Hub

hope this helps!

Thanks for the advice, I appreciate everything. I’ll try to fix it now :slight_smile:

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