✓ Accepted answer
Alright, so I was gonna do a RemoteEvent at first since you appeared to be using a LocalScript, but then I saw Stephenthefox's Comment and realized that would work better for your purposes.
Problems:
- Your table used division symbols, meaning it would error as if you were performing math on the string values
- There was a recent update on Roblox so when the Player is added you can't immediately tack on a Tool, you have to wait for the Character to load
- Calling a table's values requires you do go through the table, by using player.Name = THANOS you attempted to index the Table, resulting in a nil value for the names.
- You cannot call the Server Storage from the Client
Code:
local THANOS = {"mewant_taco", "mene_PT", "SirLenom"}
game.Players.PlayerAdded:Connect(function(player)
game.Workspace:WaitForChild(player.Name)
local backpack = player.Backpack
for index = 1, #THANOS do
local value = THANOS[index]
if player.Name == value then
local GLOVE = game.ServerStorage.SteampunkGlove:Clone()
GLOVE.Parent = player.Backpack
end
wait()
end
end)
Solutions: I edited your table to be in the proper format for this script. There is a wait function for the player's character to be loaded. The script will run through all names in the table before giving the item out. The function is based on a server-side event to call the player.
Notes: This Code MUST be run from a Script (Server-Side, NOT a LocalScript), which is best placed in the ServerScriptService.
2 comments
Do you use a normal script(server script) or a local script?
What you'll need to do is create a server script in the workspace or even "ServerScriptStorage". Then have the script wait for the event called "PlayerAdded" by using Game.Player.PlayerAdded:Connect(player). Within that event handler, you would have it check if the players name corresponds with any of the names inside the "THANOS" array. To do this, you would likely use a loop.