I am making a Minigame like thing, and I am quickly making a test so I can adapt with it. So, I went and made a function that gave all players a sword, and I was going to reverse enginner it to make it removed (im gonna have to figure that out my self), But it wont work.
This is the code I did.
function givesword() local player = game.Players:GetPlayers() local tool = script.ClassicSword:Clone() tool.Parent = player.Backpack end
If anyone knows what I am doing wrong, that will be grateful. Thanks. :P
Details: The gear is inside the script which runs the main game. The location of the script is inside ServerScriptService. Everything else works, except for giving all players the gear.
Update: So, I got the adding the sword part done, I am just having issue with removing the sword from the players.
function removesword() local players = game.Players:GetPlayers() for i, player in pairs(players) do player.Backpack.ClassicSword:Destroy() end end
This was my attempt. Ended up breaking the entire cycle. oof.
regarding SummerEquionox's comment Iterate table 'player' and give each index a new copy of 'tool'
function givesword() local players = game.Players:GetPlayers() -- GetPlayers() returns a table of players. ex: {player1, player2, player3} -- iterate or loop through the players table: for i, player in pairs(players) do local tool = script.ClassicSword:Clone() tool.Parent = player.Backpack end end