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

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

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)

3 comments

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.

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)

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

1 answer

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.

1 comment

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.

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