Option 1 - Modifying the previous remote event
First step, which is actually optional, is changing the remote event’s name to make more sense.
If you named the remote “admin_panel_open” like I did, then that’s not really making sense, as it will do more than that.
This helps avoid confusion in the future.
After that change however, we need to make edits to the code we have made earlier, as that broke it.
Remember the normal Script we made? The one that runs on the Server?
There is only one line you might have to change.
local remote = game:GetService("ReplicatedStorage").exe_storage.events.admin_panel_open
might have to change to
local remote = game:GetService("ReplicatedStorage").exe_storage.events. -- whatever you called your remote event.
Good, you made it! Since we are working with the Server Script, we might as well implement reset functionality to it!
The beginning to that is to duplicate the toggleExe function and rename it to resetExe.
Simple enough? Might say so.
local function toggleExe(plr: string, msg: string)
if msg == nil then return false end
if string.sub(msg, 1, 4) == "/exe" then
remote:FireClient(game:GetService("Players")[plr])
return true
end
return false
end
local function resetExe(plr: string, msg: string)
if msg == nil then return false end
if string.sub(msg, 1, 4) == "/exe" then
remote:FireClient(game:GetService("Players")[plr])
return true
end
return false
end
The next step is to change the line which checks if the message is “/exe” into “/resetexe”, inside of the resetExe function.
We can do this by changing the third value of the string.sub to be 9 (The length of “/resetexe”) and changing the string to be “/resetexe” itself.
You should result in having
if string.sub(msg, 1, 9) == "/resetexe" then
The second-last thing we need to do is to add false and true when calling the remote event in both functions, but in that order. I have probably chosen the worst way to say that but…
toggleExe
remote:FireClient(game:GetService("Players")[plr], false)
resetExe
remote:FireClient(game:GetService("Players")[plr], true)
I will explain why we should do this later.
The last step to the Server Script is to add this line to the script.
ChatService:RegisterProcessCommandsFunction("resetexe", resetExe)
This makes the chat actually recognize that this is a command.
Now we are moving onto the window_handler Client Script.
It will be a bit easier because we will have to copy and paste a few things that make the command actually work, instead of making our own code.
After the first change we made, we need to make edits to the code we have made, as that broke it.
There is only one line you might have to change.
local remote = game:GetService("ReplicatedStorage").exe_storage.events.admin_panel_open
might have to change to
local remote = game:GetService("ReplicatedStorage").exe_storage.events. -- whatever you called your remote event.
You might have maybe thought I copy and pasted a lot of the things in the last few sentences from the start. I am telling you right now I did not!
You might remember us putting in true
and false
when sending a signal using the remote event. This is where that comes into use. Us sending those values over the remote event actually tells the script if we want it to perform a reset or a toggle! Well actually, not yet. We have to add code in to make that work! Afterall, that’s what scripting is about… Adding and adding for things to work… Alright, we’re going too deep.
Change
remote.OnClientEvent:Connect(function()
into
remote.OnClientEvent:Connect(function(reset: boolean)
There we go!
reset
will be equal to what we send in the Server Script. (true/false)
The first if statement after that should be changed.
if not db then
to
if not reset and not db then
Lastly, after db = false
, insert this.
elseif reset then
storage.fullscreen.Value = false
controls.restore.icon.Image = "rbxassetid://11422140434"
blur.Enabled = false
if not storage.fullscreen.Value then
controls.move.Visible = true
end
tween_service:Create(main_frame, info, {Position = UDim2.fromScale(.5, .5), Size = UDim2.fromOffset(min_size.X, min_size.Y)}):Play()
tween_service:Create(main_frame.corner, info, {CornerRadius = UDim.new(0, 20)}):Play()
-- SETTING CORNERS
main_frame.menu_frame.corner.CornerRadius = UDim.new(0, 20)
main_frame.assets_panels.corner.CornerRadius = UDim.new(0, 20)
main_frame.confirmation_prompt.corner.CornerRadius = UDim.new(0, 20)
main_frame.direct_action_panels.corner.CornerRadius = UDim.new(0, 20)
main_frame.profile_panel.corner.CornerRadius = UDim.new(0, 20)
main_frame.resyncing_screen.corner.CornerRadius = UDim.new(0, 20)
main_frame.tools_panels.corner.CornerRadius = UDim.new(0, 20)
main_frame.window_controls.corner.CornerRadius = UDim.new(0, 20)
That should be all! Quite a long time it takes to make these changes!