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

Whats wrong with this Starterpack Script?

-- iLegimate --

Player = script.Parent.Parent


function ifPlayerAdmin()
	if Player.Name == "iLegimate" or "Paulyus1" or "Rrog" or "coolmist52" or "concord44" then
		x = game.ReplicatedStorage.ADMINGatesOpener:Clone()
		x.Parent = Player.PlayerGui
	end
end 


ifPlayerAdmin()

Surprisingly its giving the GUI to just anyone,Not those people only (The ones in "") Howcome? And can anyone help me debug it?

3 comments

0

The Parent.PlayerGui seems to be wrong. change player variable to Player = game.players.localplayer and out the script in localscript in startgui

0

Still doesnt work..?

0

I have added a full answer. Try that then come back if it dosen't work again.

3 answers

✓ Accepted answer

Try this in a LocalScript inside of StarterGui. The code you've supplied is quite inefficient and can be made easier.

admins = {"YourName", "SomeOtherName", "AnotherName"} --Insert people's names in here as strings, separating each one with a comma like the example shows
local player = game.Players.LocalPlayer

function isAdmin(name)
	for i = 1, #admins do
		if admins[i]:lower() == name:lower() then
			return true
		end
	end
	return false
end

player.CharacterAdded:connect(function(char)
	if isAdmin(player.Name) then
		x = game.ReplicatedStorage.ADMINGatesOpener:Clone()
		x.Parent = player.PlayerGui
	end
end)			
-- iLegimate --

LocalPlayers = game.Players.LocalPlayer

while true do
	game.Players.PlayerAdded:connect(function(player)
		if player.Name == "iLegimate" or player.Name "Paulyus1" or player.Name "Rrog" or player.Name "coolmist52" or player.Name "concord44" then
			x = game.ReplicatedStorage.ADMINGatesOpener:Clone()
		    x.Parent = LocalPlayers.PlayerGui
		    end
	end)
	wait(1)
end

Put this is a LocalScript and put that inside StarterGui The reason I believe it wasn't working was one, needs to be inside LocalScript to access the LocalPlayer, secondly, the answer above is right, it need to have Player.Name or Player.Name, etc and three, the Player variable has to be changed to Players with an s or the** Player.Name** check won't work. Hope I have helped.

If that above dosent work then try this one too

-- iLegimate --

LocalPlayers = game.Players.LocalPlayer

while true do
	game.Players.PlayerAdded:connect(function(player)
		if player.Name == "iLegimate" or player.Name == "Paulyus1" or player.Name == "Rrog" or player.Name == "coolmist52" or player.Name == "concord44" then
			x = game.ReplicatedStorage.ADMINGatesOpener:Clone()
		    x.Parent = LocalPlayers.PlayerGui
		    end
	end)
	wait(1)
end

2 comments

0

If this dosent work then change one thing

0

The one below is more efficient So I would accept that one, but make sure to thumbs up this one too.

-- iLegimate --

Player = script.Parent.Parent


function ifPlayerAdmin()
    if Player.Name == "iLegimate" or Player.Name == "Paulyus1" or Player.Name == "Rrog" or Player.Name == "coolmist52" or Player.Name == "concord44" then
        x = game.ReplicatedStorage.ADMINGatesOpener:Clone()
        x.Parent = Player.PlayerGui
    end
end 


ifPlayerAdmin()

1 comment

0

You still have to type Player.Name after or.

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