I want to make a script with a slock that a GUI will appear.
To go the issue is that I can’t get it to go ‘!slock (RANK)’ with a GUI.
I found NOOO solutions.
-- This is an example Lua code block
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
You would want to use a remote event that fires from the GUI to the server to change the value of IsServerLocked. It should look something like this:
---- local script
script.Parent.SlockButton.MouselClick:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer()
end)
---- Server script
local Serverlock = false
game.ReplicatedStorage.RemoteEvent.OnServerEvent(plr)
if Serverlock then
Serverlock = false
elseif Serverlock == true
Serverlock = false
end
end)
You can read up about remote events and there uses here:
So, do I put a local script inside the event?
No, you would want to put the local script inside the GUI that controls the Slock
1 Like
I honestly think that you should reverse where you should put the code…
1 Like
Make sure to verify that the player who fired the remote is an admin, as an exploiter can fire this remote and lock your server.
Also, if you wish it to merely toggle the “ServerLock” bool variable, you can simply do:
ServerLock = not ServerLock
1 Like
Ok, also…Do I put the GUI in ReplicatedStorage?
GUI should go in StarterGui. Remove it if the local player is not an admin. Put the remote in replicated storage. Then have a server script that toggles that variable and receives the remote’s event.
1 Like