Hey everyone! So I am trying to make a 1v1 system, and I have the rest of the code working, the only thing I cannot figure out is how to make it so that only one player can spawn on the spawn pads I have (Not spawn locations).
My spawn function:
function SpawnPlayer(player,Location)
local RandomSpawnIndexNumber = math.random(1, #Location)
local Spawn = Location[RandomSpawnIndexNumber]
if Spawn then
table.remove(Location,RandomSpawnIndexNumber)
local TeleportPlayer = script.TeleportPlayer:Clone()
TeleportPlayer.Player.Value = player
TeleportPlayer.TeleportLocation.Value = Spawn
TeleportPlayer.Disabled = false
TeleportPlayer.Parent = workspace
end
game:GetService("Debris"):AddItem(workspace.TeleportPlayer, 10)
end
My Teleport script:
local player=script.Player.Value
local Spawn=script.TeleportLocation.Value
local Character=workspace:WaitForChild(player.Name,4)
local Head=workspace:WaitForChild("Head",4)
Character.Head.CFrame=Spawn.CFrame*CFrame.new(0,5.5,0)
Didn’t work. What do you mean in the table where you say “SpawnPart1”? Because I put the path and tried to teleport them and it returned an error saying that SpawnPart1 was a bool value.
local spawns = {
[workspace.Spawns.P1] = {false},
[workspace.Spawns.P2] = {false},
}
local function SpawnPlayer(player)
for i,v in pairs(spawns) do
if v[1] == false then
v[1] = true
player.Character:MoveTo(i.Position)
break
end
end
end
Sorry I may have made a mistake. Give this a look I managed to test it and it worked fine