script.Enabled = true breaks stuff?

script works just fine, but when it’s enabled by another script, it just stops, even if it shows as enabled, i just want answers as to why this is happening, i’m tired, please


yes, i restarted both my pc and studio multiple times

1 Like

Bruh you are using a local script to enable a server script

5 Likes

and that worked before, i have an instance in this same game of that working just fine

Nah man it will never work. What changes on the client will not replicate to the server without using remote events or remote functions.

4 Likes

Yeah, you can’t enable a server script from a local script.
I also wouldn’t have that loop checking for the badge.
In a serverscript you could do something like:

game.Players.PlayerAdded:Connect(function(player)
    checkForGamepasses(player)
end)

But just be aware that changing the transparency of the door would apply to all players form a sever script so you would want to use a remoteEvent to tell the client to do whatever you need to do.
Like

if playerHasStage1Gamepass then
    openStageEvent:FireClient(player, "stage1")
end

but wouldn’t that apply to all players that have the badge, intead of only the one who clicked it?

that cannot possibly have worked, it is impossible to enable a server script from the client and if it were, the entire platform would collapse

It just might start working if he restart his pc 1 more time

1 Like

That’s where you would use that RemoteEvent to tell the client any player specific things that need to happen like I mentioned in that first post.

You can use a remoteevent


local RE = game.ReplicatedStorage:WaitForChild("ClientStuff") -- put the remote event anywhere in the replicated storage (NOT SERVER STORAGE), you'll fire it from the server script to a client script.
 
game.Players.PlayerAdded:Connect(function(plyr)
if pass then
-- check for pass, if pass is found, then do this; 

RE:FireClient(plyr) -- this will trigger a local script to fire specifically on the specified player's client 
end
end)

Then in local script:

local RE = game.ReplicatedStorage:WaitForChild("ClientStuff")

RE.OnServerEvent:Connect(Function(plyr)
game.Workspace.VIPDoor.Cancollide = false
game.Workspace.VIPDoor.Transparency = 1
end) 

Only that player will see the effect and they’ll be able to move through it since player movement is more client sided.

You can’t enable server scripts via local scripts because the server has no clue what your client is telling it to do, for all your game is concerned nothing changes unless a remote event tells it to. There’s been times where stuff like this had weird interactions on studio seeming like its working since your studio was client+server during test mode, but that’s been long fixed to properly simulate it as client vs. servers.