More issues with an obby script

Hey there, I am having more issues with my obby checkpoint script.

This is a script inside my obby checkpoint. Essentially what it does is add a stage to your leaderstats every time you touch it, but there is a debounce so you don’t collect it twice. The issue is that only one person can get the checkpoints because of the debounce. I’m wondering how I could make this so that all of this occurs:

I have another script that makes it so that when you touch the checkpoint, you respawn there, but that isn’t the issue since that is working fine.

– When you touch the checkpoint, you get the point
– Everyone can touch the checkpoint and get the point
– You can only collect it once

Please leave suggestions and solutions in the comments.

2 Likes

just check when a player touches a checkpoint, if checkpoint # = player stage + 1, then set the stage of the player, else don’t do anything. This way you don’t need debounces and people have to do stages in order

Could you be more specific? How would I get the players name? The players stage?

I’m assuming you are doing this on a serverscript, the .Touched event returns the part that touched the checkpoint, use part.Parent for the character, then use GetPlayerFromCharacter to get the corresponding player and name.

I thought you set up leaderstats already, just use that

I did exactly what you just said before. It does it to all players, not a player in specific. Which is why only one person can use the checkpoint

The idea should work, there was probably something wrong with your implementation, can you post your code?

scroll up to the very top of the post

You should use debounce for functions that should only happen once in a while. Like the function can only happen once every 3 seconds. What you are doing in this script is disabling it forever.

What you could do is have a value inside the part with the stage number. And change the value to that when the player is standing on it.

You are not checking the player’s stage and if the spawn stage is 1 more than the player’s stage, so everyone can just keep touching it, wait out the debounce, and touch again

Reason being people aren’t supposed to collect multiple stages for one stage.

And also, people are going to need to be able to come back to stages, like in other difficulty chart obbies. I don’t want them to lose their progress when going backward.

It needs to do exactly what I have it doing except for everyone, simply put.

Which includes:
– You can only collect one point when you touch the checkpoint.
– When you go back, you don’t lose your progress.
– When you touch the part you respawn there.

which is exactly why you need to check if the checkpoint is the one the player is supposed to go to. either add an intvalue containing the stage number in the checkpoint, or just simply rename the checkpoint to the number. Then when a player touches it, check if checkpointStage = player.leaderstats.Stage.Value + 1, if it is, then increment player stage, if not then just don’t do anything.

I already have it so they don’t lose their progress.

You don’t need a debounce, since after the first time the player touches the checkpoint, the stage number will no longer be one more than the player stage, so nothing happens

I don’t see why this isn’t working for all players then

Because there is a debounce. I need to make the debounce local somehow but I haven’t figured out how.

Or do something different. I don’t understand what you are proposing.

Checkpoint script:

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)

that should work

:man_facepalming:

Not what I need. I already have the checkpoint script

I just need it to work for everyone

Please tell me how I can get “checkpoint stage”