This script is a server script and when ever I run it, it gives players the number of swords of players in game. I fixed it a bit but when I tested it, it gave 1 sword to one player then 2 to the other player. I’m not sure why its not working and I have tried a few things. Help would be very appreciated!
local function Sword1()
local Players = game:GetService("Players")
-- Tables
local playerInRound = {}
local connections = {}
-- Main Script
local children = workspace.Ingame:GetChildren()
print("Worked")
for _, Player in pairs(Players:GetChildren()) do
if Player.Character and Player.Character:FindFirstChild('Humanoid') then
for i = 1,#children do
print(i)
local clone = map:FindFirstChild("Tool"):Clone()
if Player.Character:FindFirstChild("Tool") then
else
clone.Parent = children[i]
end
table.insert(playerInRound, Player)
connections[Player.name] = Player.Character.Humanoid.Died:Connect(function()
table.remove(playerInRound, table.find(playerInRound, Player))
end)
end
end
end