i tried everything including turing the spawn note that its now a spawnlocation but a checkpoint
here’s the script if that helps
local spawn = script.Parent
spawn.Touched:connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local checkpointData = game.ServerStorage:FindFirstChild("CheckpointData")
if not checkpointData then
checkpointData = Instance.new("Model", game.ServerStorage)
checkpointData.Name = "CheckpointData"
end
local checkpoint = checkpointData:FindFirstChild(tostring(player.userId))
if not checkpoint then
checkpoint = Instance.new("ObjectValue", checkpointData)
checkpoint.Name = tostring(player.userId)
player.CharacterAdded:connect(function(character)
wait()
character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
end)
end
checkpoint.Value = spawn
end
end)
You can use this code in a script. Only reed the instructions to it to work.
Put the script in the ServerScriptService.
Also if you rotate the part, in the respawn the character will rotate too.
-------------The check point need to be a “Part”----------------
-------------Put all checkpoints in the same parent---------------
-------------Put the number of checkpoint in his name-------------
-------------Change this to the parent of the checkpoints---------
local checkPoints = game.Workspace.CheckPoints
–local datastore = game:GetService(“DataStoreService”):GetDataStore(“CheckpointData”)
game.Players.PlayerAdded:Connect(function(plr)
local checkpoint = Instance.new(“IntValue”, plr)
checkpoint.Name = “Checkpoint”
----------You can make a datastore to save the checkpoint-----
–checkpoint.Value = datastore:GetAsync(plr.UserId) or 1
checkpoint.Value = 1
plr.CharacterAdded:Connect(function(char)
local root = char:WaitForChild(“HumanoidRootPart”)
local point = checkpoint:FindFirstChild(checkpoint.Value)
root.CFrame = point.CFrame * CFrame.new(0,4,0)
end)
end)
for v, check in pairs(checkPoints:GetChildren()) do
check.Touched:Connect(function(part)
local plr = game.Players:GetPlayerFromCharacter(part.Parent)
if plr then
plr.Checkpoint.Value = tonumber(check.Name)
end
end)
end
-------------------To save the checkpoint----------------
–[[
game.Players.PlayerRemoving:Connect(function(plr)
datastore:SetAsync(plr.UserId, plr.Checkpoint.Value)
end)
]]