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

[SOLVED] What's wrong with my script?

I am setting up an admin panel for my game. Everything in the script seems to be okay, but the output says the PlayerGui is not a member of Player...

What did I do wrong? How can I fix my mistakes?

Here's my code:

function Entered(Player)
	
	local isAdmin = {["Bolohuc"] = true, ["Bolohucalt"] = true, ["Bolohucalt2"] = true}
 
function findPlayer(name)
    for _, Player in ipairs(game.Players:GetPlayers()) do
        if Player.Name:lower() == name:lower() then
            return player
        end
    end
end
	
	if isAdmin[Player.Name] then Player.PlayerGui.Server.Tabs.Admin.Visible = true print(Player.Name .. "isAdmin") else print (Player.Name .. "isnotAdmin") end
	
end

game.Players.ChildAdded:connect(Entered)

I SOLVED THIS PROBLEM MYSELF. THANKS!

2 comments

0

Can you use Player.Name:lower as an argument for an if statement? Don't even know if that's possible...

0

I got this from the Roblox Wiki. I'm just using the wiki for something completely different for an admin panel. Here's where I got it from: http://wiki.roblox.com/index.php?title=Chat_commands

2 answers

local Admins = {["bolohuc"] = true, ["bolohucalt"] = true, ["bolohucalt2"] = true} -- Declare this outside of the function for global usage
-- I'd enter them in lowercase to allow the script to compare a lowercase version to them

function Entered(Player) -- This function will be called every time a Player joins the game
	if Admins[Player.Name:lower()] then
	print(Player.Name .. " is admin")
	-- It may look a little sloppy, but I'd try it.
Player:WaitForChild("PlayerGui"):WaitForChild("Server"):WaitForChild("Tabs"):WaitForChild("Admin").Visible = true
	else
		print(Player.Name .. " is not an admin")
	end
end

game.Players.PlayerAdded:connect(Entered) -- I'd use PlayerAdded

3 comments

0

Still the same error...

0

What's probably happening is the script is running before the PlayerGui is loaded. Try this.

0

Now it's saying "WaitForChild is not a valid member of PlayerGui...

Put the PlayerGui in StarterGui.

1 comment

0

Heh. I like how you downvote it. What a jerk. You don't tell us where you put the PlayerGui, so I try and help you out. Considering you have ".Visible = true", it would suggest that every player already has the GUI. My answer was logic and reasonable with the circumstances provided.

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