local Player = game.Players.LocalPlayer you = "" you2="" you3="" you4="" you5=""--players that will be able to see the gui repeat wait() until Player if Player.Name == you or you2 then local Admin = game.Lighting.gk:Clone() Admin.Parent = Player.PlayerGui else script:Destroy() end
this is meant to show a gui to certain people but it's not working I'm getting no errors. This is a localscript in startergui.
Not home to test but, I hope this works.
local Player = game.Players.LocalPlayer local Character = Player.Character ot Player.CharacterAdded:Wait() --waits for the character to be loaded local Access = { --this table stores the names of the players 'NameHere', 'NameHere', 'NameHere', 'NameHere' } local Checked = false for i,v in pairs(Access) do --loops through the table, no 'v' == the value in the table if v == Player.Name then Checked = true end end if Checked then --if checked is true then, we clone the gui to the player's PlayerGui local Admin = game.Lighting.gk:Clone() Admin.Parent = Player.PlayerGui else script:Destroy() end
Problem:
The reason you are coming up with errors is because of two major things: 1.) You need a table and 2.) You need some sort of event to pass when giving the specified player the gui you want to give. There is other problems such as location of the gui, which is not that much of a problem but it would be better to put it in replicated storage in this particular case. The reason being is because it offers more protection from exploiters and it generally helps in the long run in being able to access things in a specified place of its belonging.
Solution:
So, in your particular case you want to make a gui appear only for those that you want. Maybe friends or such. You seemed to have done this with a LocalScript, which I would highly recommend doing in a ServerScript. The reason being is because you are copying a gui from whatever place you have it, hopefully replicated storage, and putting it in the player's PlayerGui. This is how I would set up the script generally, and note this is an example and should not be copied as it may not fit how you want it.
ServerScript
local access = {["Player1"] = true, ["Player2"] = true, ["Player3"]} --This is the table I was talking about, it is called a dictionary. local replicated = game:GetService("ReplicatedStorage")--Gets the ReplicatedStorage if not there, note I used ReplicatedStorage because I prefer it local gui = replicated:WaitForChild("gk"):Clone() game.Players.PlayerAdded:connect(function(plr) --I picked this as a particular event, while yes you don't need a event it would be nice since just in cause something happens it won't pass until you want something specifically to happen if access[plr.Name] then--Checks if the player who joined the game has their name in the table by indexing the table. Which just means to take or add a value from a table. print("This player can get the gui") gui.Parent = plr:WaitForChild("PlayerGui")--Clones it else print("This player is not in the table") return nil--This is to ensure the script doesn't crash or anything end end)
Extra information:
Overall it seems you were trying to head in the right direction but tables are generally the easiest and most efficient way to go when it comes to these kind of things. It is basically what they are for. If you still do not understand anything don't fear to type a comment and ask. If this did help you then don't forget to upvote and accept the answer!