i keep spamming the reset button , sometime it will spawn at the default spawn point
here is the serverscript
local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")
local Module = require(ServerScriptService:WaitForChild("TeleportToPlayerStage"))
local function OnPlayerAdded(Player)
Player.CharacterAdded:Connect(function(Character)
repeat wait()
until Character.Humanoid
Character.Humanoid.Died:Connect(function()
print(Player.Name.." died")
Player:LoadCharacter()
print(Player.Name.."'s character loaded")
repeat wait()
until Character.HumanoidRootPart
Module.ToStage(Player)
end)
end)
end
Players.PlayerAdded:Connect(OnPlayerAdded)
here is the module
local CheckPointsFolder = game.Workspace:WaitForChild("CheckPoints")
local SpawnPoint = CheckPointsFolder:WaitForChild("SpawnPart")
local module = {}
function module.ToStage(Player)
local PlayerStage = Player:WaitForChild("leaderstats").Stage
if PlayerStage.Value > 0 then
wait()
Player.Character:MoveTo(CheckPointsFolder[PlayerStage.Value].Position + Vector3.new(0,5,0))
print(Player.Name.." stage > 0")
else
wait()
Player.Character:MoveTo(SpawnPoint.Position + Vector3.new(0,5,0))
print(Player.Name.." stage 0")
end
print("Teleported "..Player.Name.." to stage")
end
return module