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

So I placed this script below into my serverscriptservice but why doesn't it work?

Asked by 5 years ago

local name = {["blackshot43"] = true , ["powdernose88"] = true, ["Colossus001"] = true, ["Fuzi0nPr0gramz"]= true, ["Seantan8"] = true}

game.Players.PlayerAdded:Connect(function(plr)

if plr.Name == name then

script["O5 Council"]:Clone().Parent = plr.PlayerGui

end

end)

0
My game is FE enabled, This script is in ServerScriptService. So the purpose of this script is to place the gui into my playergui, Everything in the gui is Visible. But the GUI doesn't appear nor does the output outputs anything. blackshot43 7 — 5y
0
You are checking if the player's name is equal to the table, not a specific value(or key) in the table. I'm assuming you only want the people inside the table to get the Gui and you're using them as the keys in the table so to check if they should get it, you simply have to check if the key exists like so: if name[plr.Name] then end (I couldn't post an answer for some reason so here you go) User#21377 0 — 5y
0
Forgot to mention that I would recommend using the ID of the people instead of their username just in case they ever change their name, their ID is static. Just replace their names with their IDs and use this if statement: if name[plr.userId] then end User#21377 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

The issue and exceptions to what may be wrong

What you're basically doing here...

if plr.Name == name then

...is that you're comparing a string (plr.Name) to a dictionary (name). If you want to find if a name is equivalent to the player's Name, use a for loop:

for i, ChosenName in pairs(name) do
    if ChosenName == plr.Name then
        -- Something here
    end
end

You might also get yelled at for having the server access the PlayerGui. The server can access the PlayerGui itself but not its descendants with FE on. If it's still giving you an issue, you can always make the script a local script.

0
No. Index the table don't traverse the whole thing with a loop. Also FE is always forced you cannot turn it off. Also `ipairs` only browses the array part. User#24403 69 — 5y
Ad

Answer this question