I'm attempting to make a tool giver script, with the name of user's and their tools. If anyone could point me in the right direction, or even solve it yourself, that would be great!
--// added dictionary for addition of more people local Dictionary = { ["IomharOBriain"] = "Poseidon's Touch", ["BonesMcClyde"] = "Champion's Trident", ["JamesMcClyde"] = "XelGuard" } game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() for i, v in pairs(Dictionary) do if player.Name == Dictionary[i[1]] then print("success", i, player.Name) else print("fail", i, player.Name) end end end) end)
I don't really understand why you must get the first key in the dictionary, but I think this is what you wanted.
--// added dictionary for addition of more people local toolsToGive = game:GetService("ServerStorage").ToolsToGive local Dictionary = { ["IomharOBriain"] = "Poseidon's Touch", ["BonesMcClyde"] = "Champion's Trident", ["JamesMcClyde"] = "XelGuard" } game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() for i, v in pairs(Dictionary) do if player.Name == i then --We check all the keys and see if it is the same as the player's name for index, tool in pairs(toolsToGive:GetChildren()) do --If it is, get the tools in a Folder named ToolsToGive within ServerStorage if tool.Name == v then --If the tool's name is the same as the value name print("success", i, player.Name) tool:Clone().Parent = player:WaitForChild("Backpack") --We give the tool to that player. end end else print("fail", i, player.Name) end end end) end)
Explanation is inside the code block.
hahha, looking back on this two years later, sadly cringing at this sight of mess.
--// added dictionary for addition of more people local SwordKeeper = { --[[ ["IomharOBriain"] = "Poseidon's Touch", ["BonesMcClyde"] = "Champion's Trident", ["JamesMcClyde"] = "XelGuard" replace usernames with userids ]] [110029109] = "Poseidon's Touch" } game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function() local PlayerSword = SwordKeeper[player.UserId] if not PlayerSword then -- player does not have a custom sword that needed to be given return end -- .. give player their custom sword end) end)