SpawnLocations have a property called “Neutral” which if you uncheck it, it makes players unable to spawn at it by default.
1 Like
To anyone who may have the same issues this is what i came up with
local playerLastCheckpoints = {}
local function SetRespawnLocation(player, spawnLocation)
player.RespawnLocation = spawnLocation
playerLastCheckpoints[player] = spawnLocation
end
local function OnCharacterAdded(character)
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local player = game.Players:GetPlayerFromCharacter(character)
local lastCheckpoint = playerLastCheckpoints[player]
if lastCheckpoint then
humanoidRootPart.CFrame = lastCheckpoint.CFrame
end
local function OnPartTouched(part)
if part:IsA("SpawnLocation") then
if player then
SetRespawnLocation(player, part)
humanoidRootPart.CFrame = part.CFrame
end
end
end
humanoidRootPart.Touched:Connect(OnPartTouched)
end
local function OnPlayerAdded(player)
player.CharacterAdded:Connect(OnCharacterAdded)
local lastCheckpoint = playerLastCheckpoints[player]
if lastCheckpoint then
SetRespawnLocation(player, lastCheckpoint)
end
end
for _, player in ipairs(game.Players:GetPlayers()) do
OnPlayerAdded(player)
end
game.Players.PlayerAdded:Connect(OnPlayerAdded)
It goes into a localscript in StarterPlayerScripts
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.