I have this command, that if you click on a door, it teleports you to the interior of a house. But I want it to be only for me and my friends Roblox usernames (no group). How would I go about putting that in there?
local Clickness = script.Parent.ClickDetector
local Plyr = game.Players.LocalPlayer
local Remote = game.ReplicatedStorage.ScreenStuff.Fade
local Position = game.Workspace.Teleports.TurfEntrance
local using = false
Clickness.MouseClick:Connect(function(Player)
Remote:FireClient(Player)
wait(2)
Player.Character.Torso.CFrame = Position.CFrame
end)
I would use tables instead personally. It prevents a long line of every person to whitelist. Instead I would do something like this:
local Whitelist = {
1234567890, --UserId of player to whitelist
1234565432--Add more Ids to whitelist more players
}
local Clickness = script.Parent.ClickDetector
local Plyr = game.Players.LocalPlayer
local Remote = game.ReplicatedStorage.ScreenStuff.Fade
local Position = game.Workspace.Teleports.TurfEntrance
local using = false
Clickness.MouseClick:Connect(function(Player)
if table.find(Whitelist, Player.UserId) then --Sees if the player who used the command is in the whitelist table
Remote:FireClient(Player)
wait(2)
Player.Character.Torso.CFrame = Position.CFrame
end
end)
Indeed tables are a much more readable way. If you plan on the table being large, I suggest you make it a dictionary as it will lower indexing time significantly.