Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help on remote events that disable a script?

Turns out there is so much work now to disable a script in the serverscriptservice. Anyway, I have this LocalScript in the StarterGui that calls the FireServer Event:

game:GetService("ReplicatedStorage").Disable:FireServer()
--Later on in the script
game:GetService("ReplicatedStorage").Enable:FireServer()

I also have this server script:

game:GetService("ReplicatedStorage").Disable.OnServerEvent:Connect(function()
    game:GetService("ReplicatedStorage").Disable:FireAllClients()
game.ReplicatedStorage.Disable.OnClientEvent:Connect(function()
	script.Parent.Game.Disabled = true
end)
end)
game:GetService("ReplicatedStorage").Enable.OnServerEvent:Connect(function()
    game:GetService("ReplicatedStorage").Enable:FireAllClients()
game.ReplicatedStorage.Enable.OnClientEvent:Connect(function()
	script.Parent.Game.Disabled = false
end)
end)

It works in studio mode but not in game. I'm very new to RemoteEventsand RemoteFunctions, and I've already read the wiki articles but I'm still stuck. Please help me! Thank you!

2 comments

0

Try naming the RemoteEvent "DisableScript"

0

Maybe server scripts aren't used to firing clients. Try a script that fires clients in the local script.

1 answer

✓ Accepted answer
-->> Client
game.ReplicatedStorage:WaitForChild("Toggle"):FireServer(true)
-->> Server
local Toggle = game.ServerScriptService:WaitForChild("Game")

game.ReplicatedStorage:WaitForChild("Toggle").OnServerEvent:Connect(function(Enabled)
	--> Enabled is whether the script will be running after it does it stuff
	Toggle.Disabled = not Enabled
	-->> not reverses something, so if it was enabled, it would be false
end)

You cannot listen for OnClientEvent on the server. Since this changes something on the server, and not on the client, there is no need to fire it for all clients.


Hope I helped!

~TDP

3 comments

0

One question, where would I put this script in? My startergui script?

0

Woud I fire the event from the startergui script aswell?

0

Nevermind, I got it. Thank you so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.