I'm completely new to tables so I have no Idea what I'm doing with this script, but I'm re making a script for admins that will give anyone with the name of an admin a tool.
local admins = {"darkblooood"} game.Players.PlayerAdded:Connect(function(player) if admins == player.Name then print(player.Name) end end)
Hi, hope this helps! You're going to need the put the name of your tool in serverstorage, because we will clone the tool into the players backpack. Put this server script in workspace.
local admins = {"darkblooood", "AnotherAdmin", "Adminsusername"} local gear = game.ServerStorage.Toolnamehere -- This creates a variable for your tool in server storage(Make sure to rename toolnamehere to your tool name) game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(chr) for i = 1, #admins do if admins[i] == plr.Name then gear:Clone().Parent = plr:WaitForChild("Backpack") end end end) end)
Let me know if you have any questions, and feel free to accept if it helped! It should work!
To make comparisons to items in a table, you simply loop through the table and compare each individual item using a for
loop.
Here's an example:
local player = game.Players.LocalPlayer local examplePlayer = "darkblooood" local exampleTable = {"item1", "apple", examplePlayer} for i, exampleItem in pairs(exampleTable) do -- syntax for this loop is: -- for [index variable name], [value variable name] in pairs([table name]) do if player.Name == exampleItem then print(player.Name) end end
Hope this helps :)