Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

[SOLVED] What's wrong with my script? [closed]

Asked by
sgsharp 265 Moderation Voter
10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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!

0
Can you use Player.Name:lower as an argument for an if statement? Don't even know if that's possible... OniiCh_n 410 — 10y
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 sgsharp 265 — 10y

Locked by 1waffle1 and Articulating

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
0
Answered by
Ekkoh 635 Moderation Voter
10 years ago
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
0
Still the same error... sgsharp 265 — 10y
0
What's probably happening is the script is running before the PlayerGui is loaded. Try this. Ekkoh 635 — 10y
0
Now it's saying "WaitForChild is not a valid member of PlayerGui... sgsharp 265 — 10y
Ad
Log in to vote
-1
Answered by
c0des 207 Moderation Voter
10 years ago

Put the PlayerGui in StarterGui.

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. c0des 207 — 10y