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

[Solved] How to check if Player Names match Names in Table of Module Script?

Asked by 5 years ago
Edited 5 years ago

So... I wanted to ask how I can check if a Player's name matches one name inside a table inside a Module script...

Module Script

local ShowGui = { "Player1","Player2"}

return Whitlelisted

Local Script

local Settings = require(game.Workspace.Settings)

local sg = Settings.ShowGui

game.Players.PlayerAdded:connect(function(p)
    if sg[p.name] then
        script.Parent.Parent.ScreenGui:Clone().Parent = game.Players.LocalPlayer.PlayerGui
    end
end)

Well.. I don't get any erros it just doesn't works...

Is it because my "Caller" Script is a Local Script and not a Normal script?

I made it to a local script because I want to access the LocalPlayer.

Would it work with script.Parent.Parent.ScreenGui:Clone().Parent = p.PlayerGui?

It's maybe a bit too much what I wrote but.. I think this explains my problem in detail.. (I hope)

I just don't know what I did wrong...

Also I am sorry if that local ShowGui = {} thingy is not a Table.. I mostly say wrong names I just really have to learn the name differences :P

Edit:

No need to help anymore. Solved it myself after trying and trying

1
Arrays are mappings from `1...#array` to arbitrary Lua values, and to get something out of an array you can do `array[1]`, `array[2]`, `array[3]`, etc etc, they are integer keys, not string keys. So you'll want to use a dictionary or loop through the array User#24403 69 — 5y
0
Also don't make it a local script or else PlayerAdded doesn't fire for the local player User#24403 69 — 5y

Answer this question