This checkpoint is not working. Can I get a little bit of help please? Thank you.
local Base = script.Parent.Base
local TeleportPos = script.Parent.TeleportPoint
local HasCheckpoint = script.Parent.HasCheckpoint
HasCheckpoint = false
CheckpointValue = 1
Base.Touched:Connect(function(hit)
local h = hit
if h then
local p = Base:FindFirstChild("Humanoid")
if p then
print(p.Name.." has got checkpoint "..CheckpointValue)
wait()
HasCheckpoint = true
HasCheckpoint()
else
print("Cannot find Humanoid in Base.Touched _, Line 14 of "..script.Name.." in "..script.Parent.Name)
end
end
end)
function HasCheckpoint()
local SpawnLocation = Instance.new("SpawnLocation")
SpawnLocation.Name = "Spawnlocation"..CheckpointValue
SpawnLocation.Parent = game.Workspace
SpawnLocation.Transparency = 1
SpawnLocation.Decal:Remove()
SpawnLocation.CanCollide = false
SpawnLocation.Anchored = true
SpawnLocation.Position = TeleportPos.Position
SpawnLocation.Size = TeleportPos.Size
local OriginalSpawn = game.Workspace:FindFirstChild("Spawnlocation"..game.ReplicatedStorage.SpawnLocationValue.Value -1)
if OriginalSpawn then
OriginalSpawn:Remove()
else
warn("Cannot find OriginalSpawn")
end
end