I attempted to make this function that ready's 2 randomly chosen players to fight:
local function readyduelers(dueler) dueler.Character:MoveTo(spawn1.Position) local swordclone = sword:Clone() swordclone.Parent = dueler.Backpack dueler.Character.Humanoid.WalkSpeed = 0 end
The code I used to choose the players and call the function:
_G.duelers = {} local players = game.Players:GetPlayers() local dueler1 = players[math.random(1, #players)] repeat dueler2 = players[math.random(1, #players)] until dueler2 ~= dueler1 table.insert(_G.duelers, dueler1.Name) table.insert(_G.duelers, dueler2.Name) readyduelers(dueler1, dueler2)
The problem is, it's only teleporting player 1, even though I did "readyduelers(dueler1, dueler2)". I'm not sure how to fix this and any help is appreciated.
Try:
local function readyduelers(dueler1,dueler2) dueler1.Character:MoveTo(spawn1.Position) local swordclone = sword:Clone() swordclone.Parent = dueler1.Backpack dueler.Character.Humanoid.WalkSpeed = 0 dueler2.Character:MoveTo(spawn1.Position) local swordclone = sword:Clone() swordclone.Parent = dueler2.Backpack dueler2.Character.Humanoid.WalkSpeed = 0 end
_G.duelers = {} local players = game.Players:GetPlayers() local dueler1 = players[math.random(1, #players)] repeat dueler2 = players[math.random(1, #players)] until dueler2 ~= dueler1 table.insert(_G.duelers, dueler1.Name) table.insert(_G.duelers, dueler2.Name) readyduelers(dueler1, dueler2)
The problem was that you were feeding readyduelers() two variables, but in the actual function it only had one.