So I'm trying to implement a script where players in the 'prisoners' team are teleported to a unique cell that will be given only to them. But with the script below I get an error:
ServerScriptService.Script:22: invalid argument #2 to 'random' (interval is empty)
Voici mon script :
local RemoteEvent = game.ReplicatedStorage.ChangeTeam
FreeCellsList = {
CL1 = workspace.CellLocation1,
CL2 = workspace.CellLocation2,
CL3 = workspace.CellLocation3
}
RemoteEvent.OnServerEvent:Connect(function(player,teamcolor)
player.TeamColor = teamcolor
player:LoadCharacter()
wait(0.1)
--Underneath, assign a cell for each player in the team
local keys = {}
for k in pairs(FreeCellsList) do
table.insert(keys,k)
end
if player.TeamColor == BrickColor.new("Deep orange") then
local ChoiceIndex = math.random(1,#FreeCellsList)
local ChoiceKey = keys[ChoiceIndex]
local choice = FreeCellsList[ChoiceKey]
table.remove(FreeCellsList,ChoiceIndex)
player.Character.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.choice.Position)
print("Téléporté à une cellule aléatoire")
end
end)
Thanks in advance !

2 comments
Why is the "teleport print" in spanish or something?
Its french cause Im french lol