I am trying to make a game with checkpoints in it. i made the script but when you try touching the checkpoint and then dying to see if it works it doesn't. No error's no nothing.
Here is the script:
local checkpoint = script.Parent
function OnCheckpoint(part)
if part.Parent and part.Parent:FindFirstChild("Hunanoid") then
local plr = game.Players:GetPlayerFromCharacter(part.Parent)
local checkpointData = game.ServerStorage:FindFirstChild("checkpointData")
if not checkpointData then
checkpointData = Instance.new("Model")
checkpointData.Parent = game.ServerStorage
checkpointData.Name = "CheckpointData"
local savedCheckpoint = checkpointData:FindFirstChild(player.Name)
if not savedCheckpoint then
savedCheckpoint = Instance.new("ObjectValue")
savedCheckpoint.Parent = checkpointData
savedCheckpoint.Name = player.Name
function SpawnToCheckpoint(character)
wait()
local location = savedCheckpoint.Value.CFrame
character:WaitForChild("HumanoidRootPart").CFrame = location + Vector3.new(0, 4, 0)
print("cool")
end
player.CharacterAdded:Connect(SpawnToCheckpoint)
end
savedCheckpoint.Value = checkpoint
end
end
checkpoint.Touched:Connect(OnCheckpoint)
end

1 comment
plz answer