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

Admin panel not working with a for loop going through a table?

So i'm trying to make an admin panel and I have all of the localscript done and im handling the rest on the server and I have this admin table that shows all the names of the admins but when I go to run the script when I fire the RemoteEvent it shows "Working" 4 times in the console yet the button doesn't do anything and it wont print errors? Here is my code:

Admins = {"Nob", "Elypanft", "GamerPlayesRoblox_YT", "Player1"}
remote = game.ReplicatedStorage.Admin

game.Players.PlayerAdded:Connect(function(player)
	for _, v in pairs(Admins) do
		if player.Name == v then
			game.Players[player.Name].PlayerGui:WaitForChild("Admin").Enabled = true
		end
	end
end)


function kick(a,b)
	game.Players[a]:Kick(b)
end

function freeze(a)
	game.Players[a].Character.Humanoid.WalkSpeed = 0
	game.Players[a].Character.Humanoid.JumpPower = 0
end

function unfreeze(a)
	game.Players[a].Character.Humanoid.WalkSpeed = 16
	game.Players[a].Character.Humanoid.JumpPower = 50
end

function admin(a)
	Admins.Add(a)
end

function teleport(a, b)
	local targetplayer = game.Players[b].Character.HumanoidRootPart
	game.Players[a].Character.HumanoidRootPart.CFrame = CFrame.new(targetplayer.Position.X, targetplayer.Position.Y, targetplayer.Position.Z)
end

remote.OnServerEvent:Connect(function(player, cmd, target, reason)
	for _, v in pairs(Admins) do -- it loops 4 times here when i want it to loop once
		print("Working")
		if player.Name == Admins then
			if cmd == "Kick" then
				kick(target, reason)
			end
			if cmd == "Freeze" then
				freeze(target)
			end
			if cmd == "Unfreeze" then
				unfreeze(target)
			end
			if cmd == "Admin" then
				admin(target)
			end
			
			if cmd == "TeleportTo" then
				teleport(player, target)
			end
		end
		
		if not player.Name == Admins then -- checks if a nonadmin fired the remote
			game.Players[player]:Kick("Exploiting Admin Panel")
		end
	end
end)

3 comments

0

Um. I thought you can only send two things through remote events...... Sending more makes the serverside code break. Also if you are trying to make an exploit... You can't use remote events unless they already existed in the game. Also you kick doesnt have a target. Please show your full code including the server side parts

0

I'm making my admin panel exploit proof and this is all the serverside stuff

0

You must be shit at code because my kick works just fine now I fixed it its just i put admins instead of v

1 answer

Instead of "if player.Name == Admins then", put "if player.Name == v then", as Admins, is the name of the table, and v is the value stored in the table, being one of the admins! :)

Hope this helped, let me know if it fixed your problem, Thanks!

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