local module = {}
module.Checkpoint = function(CheckPointPad,stageNumber)
CheckPointPad.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local Debounce = false
local character = hit:FindFirstAncestorOfClass("Model")
if player.leaderstats.Stage.Value >= stageNumber then
return
else
if Debounce == false then
Debounce = true
print("StageUp")
player.leaderstats.Stage.Value = player.leaderstats.Stage.Value + 1
wait(4)
Debounce = false
end
end
if character then
local Player = game.Players:GetPlayerFromCharacter(character)
if Player and Player.RespawnLocation ~= CheckPointPad then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid and humanoid:GetState() ~= Enum.HumanoidStateType.Dead then
print("SpawnSet")
Player.RespawnLocation = CheckPointPad
end
end
end
end
end)
end
return module
i don’t know how to fix it