Admin button not working

The following script:

cool_people = {id1,id2}

game.Players.PlayerAdded:Connect(function(Player)
	if table.find(cool_people, Player.UserId) then
		script.Parent.Visible = true
	else
		script.Parent.Visible = false
	end
end)

Is supposed to make the button visible if the user ID is equal to any of the 2 id’s. It does not show any error messages and it does not show up. I have no idea why this is happening.

the script has no logical error, try debugging using print statements once and let me know if the code is running.

I added 3 print statements:

print("running")
cool_people = {id1,id2}

game.Players.PlayerAdded:Connect(function(Player)
	if table.find(cool_people, Player.UserId) then
                print("userid match")
		script.Parent.Visible = true
	else
                print("no userid match")
		script.Parent.Visible = false
	end
end)

Only the running statement prints.

1 Like

is this a local script ?

No, I tried changing it to one, but it did not work. This is where it is:

so here’s the issue, you have parented the server script to an UI. server scripts won’t work if you parent it to an UI, you this scripts instead

Server Script
local Cool_Players = {}
local RemoteEvent = --A remote event

game.Players.PlayerAdded:Connect(function(Plr)
 if table.find(Cool_Players, Plr.UserId) then
  RemoteEvent:FireClint(Plr, "Is A Cool Player")
 end
end)
Clint Script
local RemoteEvent = --A remote event

RemoteEvent.OnClintEvent:Connect(function(v1)
 if v1 == "Is A Cool Player" then
  script.Parent.Visible = true
 end
end)

I haven’t tested the script, so there might be some errors, if you won’t get the fix, put it here and ill help you out

1 Like

10:12:11.775 OnClintEvent is not a valid member of RemoteEvent “ReplicatedFirst.cool_admin_guy” - Server - admin id:3
There is also a red underline on Cool_Players for “Unknown Global Cool_Players” on the same script.
I placed the client script in the same place and the server script in the ss service and also made a remote event and placed it on the dedicated places.

1 Like

Oh. a mispelling. Change Onclintevent to OnClientevent

I made a mistake, which is creating that red underline, you can copy past the script now from here, forgot to remote a part code last time. The code is fine now.

1 Like

Still does not work, this time no errors. These are the modifications I made:

Client script
local RemoteEvent = game.ReplicatedFirst.cool_admin_guy

RemoteEvent.OnClientEvent:Connect(function(v1)
	if v1 == "Is A Cool Player" then
		script.Parent.Visible = true
	end
end)
Server script
local Cool_Players = {id,id}
local RemoteEvent = game.ReplicatedFirst.cool_admin_guy

game.Players.PlayerAdded:Connect(function(Plr)
	if table.find(Cool_Players, Plr.UserId) then
		RemoteEvent:FireClient(Plr, "Is A Cool Player")
	end
end)

I have to go now, I’'ll be back later in an hour or 2.

1 Like

try debugging using print statements

Have you tried doing it this way too?

table.find(cool_people, "", Player.UserId)

Parent this script to ServerScriptService (Remove your older scripts too). Next up put the Admin UI button inside the script. and it should work.

local cool_people = {id1,id2}

game.Players.PlayerAdded:Connect(function(Player)
	if table.find(cool_people, Player.UserId) then
		script["Admin UI"].Parent = Player.PlayerGui.Menu.menu
	end
end)

Make sure to mark it as a solution if it helped.