So I create my own spawn locations and after player joins the game character spawn in a certain position.
So the main question is: how do I make the player spawn in a certain position after he reset his character?
this is the current code:
game.Players.ChildAdded:Connect(function(player)
repeat wait() until player.Character ~= nil
local spawnLocations = game.Workspace.spawn_locations:GetChildren()
local selectedSpawnLocation = spawnLocations[math.random(1, #spawnLocations)]
player.Character.HumanoidRootPart.CFrame = selectedSpawnLocation.CFrame
end)
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
repeat wait() until character ~= nil
local spawnLocations = game.Workspace.spawn_locations:GetChildren()
local selectedSpawnLocation = spawnLocations[math.random(1, #spawnLocations)]
character:PivotTo(selectedSpawnLocation.CFrame)
end)
end)