Check If In-Game Staff Member is in a Standard Server

Hello!

My game that I’m working on is to those of WWE servers, for example: Entrance Practice. I’ve been doing a CleanHandler checks certain things. What the script checks is that if the game is in a private server, if the private server owner is in said private server, if there is a staff in the server, or if the server has no staff and is public.

I worked on this script for a little bit, but I realized my code won’t work for everybody. From the code below, it made it so that if the player is staff, it would print, but with the else statement, it’s going to allow players to use the Clean—a tool where you can damage other players—which would ruin the event me and my cousin made.

Now, would anyone help me figure out how to make it where if an in-game staff member is in a standard server, players that aren’t staff won’t be given the Clean? I’m believing that my script would only make my staff members not have the Clean.

--// Variables
local Players = game:GetService("Players")
local StarterPack = game:GetService("StarterPack")
local Clean = game:GetService("ReplicatedStorage").Gears:WaitForChild("Clean")
local Staff = {3942242726, 1145448158}

--// Script
Players.PlayerAdded:Connect(function(plr)
	if game.PrivateServerId ~= "" then
		if game.PrivateServerOwnerId ~= 0 then
			print("In a VIP server; cleans are handed out by VIP server owner")
		else
			Clean:Clone().Parent = plr.Backpack
			print("In a reserved server; cleans are handed out automatically")
		end
	else
		for i, v in ipairs(Staff) do
			if v == plr.UserId then
				print("In a standard server with staff; cleans are handed out by staff")
			else
				Clean:Clone().Parent = plr.Backpack
				print("In a standard server; cleans are handed out automatically")
			end
		end
	end
end)

I redid the script a bit to try and find a nice solution to it. I believe that this should work:

--// Variables
local Players = game:GetService("Players")
local StarterPack = game:GetService("StarterPack")
local Clean = game:GetService("ReplicatedStorage").Gears:WaitForChild("Clean")
local Staff = {3942242726, 1145448158}
table.insert(Staff, game.PrivateServerOwnerId) -- you can add this to the staff table initially if you want

--// Script
Players.PlayerAdded:Connect(function(plr)
	if table.find(Staff, plr.UserId) then
		Clean:Clone().Parent = player.Backpack
	end
end)

I’m not 100% sure that I understood what you wanted it to do, so the code above gives the player the tool if the player is:

  • A staff member, as defined by the table on line 5, or
  • The owner of the private server

Pretty much is that if someone that is apart of staff team joins or if the private server owner joins, the members’ Clean will be removed from their backpack.