Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to not give the player the checkpoint if they are already dead?

I made a checkpoint system and it works. Whenever the player passes over the block it goes to the leaderstats and adds 1. Not only does it add +1 it will also save you progress so if you die you respawn there. The problem is that if I die and just 1 part of the body hits the block it counts it and does +1 and saves your progress. I want it so you have to be alive and walk over it and it gives the checkpoint. Note: I have a folder named checkpoints parts in it.

local checkpoints = workspace:WaitForChild("Checkpoints")

game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = plr
	
	local v = Instance.new("IntValue")
	v.Name = "Stage"
	v.Value = 1
	v.Parent = leaderstats
	
	plr.CharacterAdded:Connect(function(char)
		local hum = char:WaitForChild("Humanoid")
		wait()
		char:MoveTo(checkpoints[v.Value].Position)
		
		hum.Touched:Connect(function(hit)
			if hit.Parent == checkpoints then
				if tonumber(hit.Name) == v.Value +1 then
					v.Value = v.Value +1 
				end
			end
		end)
	
	end)
	 
end)

1 comment

0

There's a thing called Debounce. (Cooldown).

1 answer

✓ Accepted answer

make sure to check if the humanoid Health > 0 doing this

char.HumanoidRootPart.Touched:Connect(function(hit)
	if hit.Parent == checkpoints and char.Humanoid.Health > 0 then
		if tonumber(hit.Name) == v.Value +1 then
			v.Value += 1
		end
	end
end)

1 comment

0

with this you should remove your pre-existing hum.Touched event block

This discussion is preserved as it was. New answers, comments, and votes are closed.