Enter Song ID For Admin Only

Hello Devs, I have a small question for you. I am currently working on a “hangout” game (something I never thought I would try to make but here I am) and need help with a certain script. As you probably have read the title, I am trying to make an “Input Song ID” GUI that only certain people (mods or admin) can use and input a song ID. How can I make the GUI so where only selected people can access and view it? I hope this was detailed enough for it to make sense.

p.s. I’m going to bed soon so I won’t respond for the next 6-8 hours (no school tomorrow!)

Hey,
you can simply achieve it by storing your ‘AdminGui’ in ServerStorage and make table of UserIds for admins that will get cloned version of this to their playergui.

2 Likes

You can put the ScreenGui for your Input Song thing somewhere such as ServerStorage and make it so when a player joins, it checks something, such as a table of the UserIds considered as Admins on the UserId of the player who joined and clone that ScreenGui into their PlayerGui

@caviarbro had already stated that before me but to explain it a bit more, here’s an example assuming SongGui is a ScreenGui in ServerStorage

--Services
local players = game:GetService("Players")
local servStorage = game:GetService("ServerStorage")

local songGui = servStorage.SongGui

--Admin Ids
local ids = {
	1745848,
	1526373,
	63859378,
	--Add more if needed
}

--Detect when a player joins
players.PlayerAdded:Connect(function(player) 
	local plrGui = player:WaitForChild("PlayerGui")
	if table.find(ids,player.UserId) then --Is UserId in table?
		songGui:Clone().Parent = plrGui --Clone Gui into player
	end
end)

I didn’t make a variable for the cloned Gui since all we’re doing here is setting a single properyy (the Parent property), but if you have to change 2 or more, such as the Enabled Property and the Parent Property, you will have to put songGui:Clone() into a variable and reference that.

I believe the ScreenGui should have ResetOnSpawn disabled so it persists on respawn as well

3 Likes

@caviarbro @EmbatTheHybrid

I am giving an error,
Screenshot 2021-04-15 095024

I must have done something wrong with the script, should it be a local script? Also, where should I put it?

(sorry if I am asking to many questions, I am a GFX artist so scripting isn’t in my strong point)

The code I gave was an example, you have to put your ScreenGui for the song id gui into ServerStorage and change the SongGui in

local songGui = servStorage.SongGui

to the name of the gui

1 Like

yes I was aware of that, so that is why I changed the “ScreenGUI” title to SongGUI so it would fit the code. That ended up not working.

Try changing

local songGui = servStorage.SongGui

To

local songGui = servStorage:WaitForChild("NameOfYourScreenGuiHere")

And just change NameOfYourScreenGuiHere with the name of your screengui

Alright, but where should I put the script? In the GUI, ServerScriptStorage, Workspace?

ServerScriptService should be good

So I have the “ScreenGUI” (with a image label to test) in Server Storage and one LocalScript (with your code). And yet after I press play, the ScreenGUI does not pop up on my screen and nothing is shown in the Output.

(sorry if I’m bothering you with this, I really need this to finish this by tomorrow)

Put the code in a regular script in ServerScriptService, not a localscript. Localscripts do not run in SSS

Ok it works! I want to thank both you and @caviarbro for helping me. Take care :+1:

2 Likes

No problem, @EmbatTheHybrid knows what is she doing and he is amazing in it! Stay safe ;).

1 Like

Okay how come everyone sees me as a he haha, I’m a she!

@jxzzify And anytime! if you hae anymore issues don’t be afraid to maek another post!

2 Likes