Menu Don't Show When Respawn

Hey Guys, I need help with an admin menu.

local ServerStorage = game.ServerStorage
local AdminsMenu = ServerStorage:WaitForChild("AdminMenu")

admins = {0000000000,0000000000,0000000000}
game.Players.PlayerAdded:Connect(function(plr)
	if table.find(admins, plr.UserId) then
		game.SoundService.promotion.Volume = 0.3
		local adminPanel = AdminsMenu:Clone()
		adminPanel.Parent = plr.PlayerGui
		adminPanel.Enabled = true
	else
		game.SoundService.promotion.Volume = 0
	end
end)

This script makes an admin menu and clones this admin menu inside plrGUI for specific players, but the problem is that when they die or respawn, the menu does not show up again.

This is due to the fact when you call ‘PlayerAdded’ it only calls a single time! This is because PlayerAdded is called when the player is added to the server.

Documentation on CharacterAdded.

Inside of PlayerAdded I’d recommend adding a plr.CharacterAdded:Connect function, then calling your code starting with if table.find...

Does this fix your issue?

does not work?

local ServerStorage = game.ServerStorage
local AdminsMenu = ServerStorage:WaitForChild("AdminMenu")

admins = {0000000000,0000000000,0000000000}
game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function()
		if table.find(admins, plr.UserId) then
			game.SoundService.promotion.Volume = 0.3
			local adminPanel = AdminsMenu:Clone()
			adminPanel.Parent = plr.PlayerGui
			adminPanel.Enabled = true
		else
			game.SoundService.promotion.Volume = 0
		end
	end)
end)

Did you add your PlayerId to the admins table?

Yes, I did, and when I click play, it shows, but when I die, it does not show again.

Perhaps if I make a loop forever, every time I spawn, the server will lag.

Edited: Nevermind if I Do a loop it will clone infinity

Adding a task.wait() inside of the above if.table.find... will solve your issue.

Set adminPanel.Enabled to true BEFORE moving it to the player.
Try disabling ResetOnSpawn (or whatever it’s called…)

this?

image

Yeah, this works; thank you, bro.

Good to hear brother! Keep on posting to get your scripting questions answered!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.