"Admin" script is broken - works only once

I spent a few days trying to figure out how to fix the bug. In the end, I did it, thanks to those who tried to help.

I made an admin script and every command works only once and then stops working, I am using a blind command, then unblind and when I try to blind myself again it won’t work. But as you can see, the output is working normally. How to fix this?

(Also, I’m a beginner in scripting so expect stupid mistakes)
This script works through RemoteEvent

LocalScript
script.Parent.FocusLost:Connect(function()
	local remoteEvent = script.Parent:WaitForChild("GlobalCMD")
	local txt = script.Parent.Text
	
	for i,v in pairs(game.Players:GetPlayers()) do
		
		if txt == "blind "..v.Name then
			print("Sent data")
			
			remoteEvent:FireServer(txt, v, "blind")
			
			script.Parent.Parent.OpenCMD.Disabled = false
			script.Parent.Text = ""
			script.Parent.Visible = false
		
		
		elseif 
			txt == "unblind "..v.Name then
			print("Sent data")
			remoteEvent:FireServer(txt, v, "unblind")
			
			script.Parent.Parent.OpenCMD.Disabled = false
			script.Parent.Text = ""
			script.Parent.Visible = false
		
		
		elseif 
			txt == "cmds" then
			script.Parent.Parent.CMDList.Visible = true
			script.Parent.Parent.OpenCMD.Disabled = false
			script.Parent.Text = ""
			script.Parent.Visible = false
		else
			script.Parent.Parent.OpenCMD.Disabled = false
			script.Parent.Text = ""
			script.Parent.Visible = false
		end
		
	end
end)
Script
local remoteEvent = script.Parent:WaitForChild("GlobalCMD")
remoteEvent.OnServerEvent:Connect(function(plr, txt, name, cmd)
	

		
		-- Blind command
	if cmd == "blind" then
		
		name.PlayerGui.JCMD.ScriptsForPlayers.Blind.Disabled = false
		print("Blind command sent")
		print(name.Name)
		print("Script disabled status: "..tostring(name.PlayerGui.JCMD.ScriptsForPlayers.Blind.Disabled))
		

		
		-- Unblind command
	elseif 
		cmd == "unblind" then
		
		name.PlayerGui.JCMD.ScriptsForPlayers.UnBlind.Disabled = false
		print("Unblind command sent")
		print(name.Name)
		print("Script disabled status: "..tostring(name.PlayerGui.JCMD.ScriptsForPlayers.Blind.Disabled))
		
	end
	
end)

Output:
image
I ran a blind command, then an unblind command, they worked. But then I ran a blind and unblind again and they didn’t work. But the output worked normally.

Also, there is an explorer, if it will help somehow.
image

1 Like

the command probably works once because you enable the local scripts and it never gets disabled again. Also, I would recommend doing all of the commands from the script itself or having module scripts you can require to get the command data. Running it from local scripts will just affect everyone as you enable it from a server script. Also, do security checks because hackers can use this freely as you do not check whether they are an admin or not. You could also use a Remote Event for the camera blur, and have a .OnClientEvent in a local script to handle the blur. Hackers can not use :FireClient() as it only works inside of server scripts.

1 Like

Unfortunately, none of the above methods worked.

This admin system in general is just more difficult than it needs to be. Rather than using separate scripts for every command and enabling/disabling the scripts to execute the code, try keeping all code in one module. You can keep each command as a function:

function Module:Blind(Target)
   --Blind the player
end

You can execute this in a server script with the same .Chatted event.

Player.Chatted:Connect(function(Message, Recipient)
     if Message == "blind" then
         Module:Blind(Target)
     end
end)

With your current system, it’s really annoying having to enable and disable a script.