ServerScript Not Running When Enabled By LocalScript

hello, i’m making a horror game and i’ve created a part with a serverscript inside of it, basically making it so that if the player steps on the part, objects in replicatedstorage move to workspace. i disabled that script.

the problem is that theres a localscript in startergui thats supposed to ENABLE that serverscript, and when i test, the serverscript is enabled, but none of it is functioning/running like i want it to.

i’ve been facing this problem for a while now, so any help would be GREATLY appreciated! :slight_smile:

ServerScripts cannot be enabled or disabled by LocalScripts. Instead, use RemoteEvents, and have another ServerScript enable the script for you.

2 Likes

As @kexy123 said, You can’t enable a serverScript in a LocalScript.
use RemoteEvents.

Code example :

-- local script

local event = game.ReplicatedStorage.RemoteEvent -- insert your remoteEvent here

wait(5) -- the time you want to enable the serverscript
event:FireServer()
-- server script

local event = game.ReplicatedStorage.RemoteEvent -- insert your remoteEvent here

local function somethingtoDo()
    -- something you want to do when event is fired
end

event.OnServerEvent:Connect(somethingtoDo)
1 Like

thank you so much, i got it to work with a remote event!

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