Help, this script wont enable after I disable it

Hello there fellow developer,

I have some problem. My script can’t be enabled after it has been disable. I have use two script to use this. This is the first script.

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local StarterPlayerScripts = game.StarterPlayer:FindFirstChild("StarterPlayerScripts")

game.Players.PlayerAdded:Connect(function()
	if StarterPlayerScripts:FindFirstChild("script") then
		script.Disabled = true
	end
end)

Second script.

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local StarterPlayerScripts = game.StarterPlayer:FindFirstChild("StarterPlayerScripts")
local Script = script.Parent.Script

game.Players.PlayerAdded:Connect(function()
	if not StarterPlayerScripts:FindFirstChild("script") then
		Script.Disabled = false
	end
end)

Please tell me what is wrong. I dont know why it won’t enable.

Edit: The script is located in SSS (Server Script Service).

1 Like

You can’t access server script service with a local script, use a remote event instead of enabling scripts.

I meant the script where I’m having a problem is in Server Script Service.

The script(the one you wrote) is disabled and forever will be disabled. Nothing will work then. :slight_smile: I have no clue what your real intention is behind this.

Note script.Disabled.

It is as if you were to make the script deactivate itself without reactivation after attempting activating it from something that has been disabled.

3 Likes

Hm…, Interesting. Thank you for the response.

Try this:

game.Players.PlayerAdded:Connect(function(player)
	if player.PlayerScripts:FindFirstChild("script") then
		script.Disabled = true
	end
end)

Anything (only scripts) in starter player scripts/ starter character scripts are replicated into player scripts
If this reply solved your problem, you can mark it as the solution.

1 Like

It wont work. It said PlayerScripts is not a valid member of Player.

Try using WaitForChild()
player:WaitForChild(“PlayerScripts”):FindFirstChild(“script”)

Yep, your right. It doesnt detect it.

I think it read script as it’s self. You might want to use another script in server scripts to help you with it like

script.Parent.NameOfYourFirstScript

Or you might want to change the name of your script and then change the FindFirstChild() accordingly

But I tried to use StarterCharacterScripts and the enabling part did not worked.

I already changed the script name.

Maybe you should do this to disable and enable your script

I use two scripts. One is to disable it self and one to enable the other one.

Maybe you should use one script to disable and enable the other one

I dont get what you mean. Please explain it to me.

So you should do something like
Script 2

--Code if there is
script.Parent.Script1.Disabled = true
--Code or else just put a wait
script.Parent.Script1.Disabled = false
--Code if there is

Script1

--Remove the disabling part and keep the rest of the code

Edit: That’s if your 2 scripts are under the same parent

1 Like

It still doesn’t enable the disable script.
Edit: Never mind it works thanks.

Did you modify the given code? Or did you at least have a wait?

I dont have any wait I only have this

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local StarterPlayerScripts = game.StarterPlayer:FindFirstChild("StarterPlayerScripts")
local Script = script.Parent.Script

game.Players.PlayerAdded:Connect(function()
	if not StarterPlayerScripts:FindFirstChild("script") then
		Script.Disabled = false
	end
end)

I disable the script at the studio before it got launch.
Edit: The other script