Does not register the stage when touching the checkpoint FFR

Hello!

I have been working on a project for about 5 months that has brought me several scripting problems, well it is a bike game, I have reused the x_0 bike system by creating several sections, one of them is an obby

I’m also using a Wolfite obby system. I have tried to sync these 2 systems and it worked more or less, but the error here is that when I touch a checkpoint it does not register it, however, if I buy the SKIP STAGE it does register it

This system does not use the real player character, but a replica
To understand the above a little more, what I need is that when the fake player touches a checkpoint, +1 stage is added to their leader stats.

2

Below I leave a part of the code that does not fulfill its function of adding +1 stage to player

for _, v in pairs(workspace.Stages:GetChildren()) do
	v.Touched:Connect(function(hit)
		if v and v.Parent == workspace.Stages then
			local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
			if plr then

				if Configurations.AnyCheckpoint then
					if plr.Character:WaitForChild("Humanoid").Health > 0 then
						if tonumber(v.Name) > plr.leaderstats.Stage.Value then
							plr.leaderstats.Stage.Value = tonumber(v.Name)
							plr.TStage.Value = plr.leaderstats.Stage.Value
						else
							plr.TStage.Value = tonumber(v.Name)
						end
					end
				else
					if plr.Character:WaitForChild("Humanoid").Health > 0 then
						if plr.leaderstats.Stage.Value == tonumber(v.Name) - 1 then
							plr.leaderstats.Stage.Value += 1
							plr.TStage.Value = plr.leaderstats.Stage.Value
						elseif plr.TStage.Value < tonumber(v.Name) - 1 then
							plr.TStage.Value += 1

						end
					end
				end
			end
		end
	end)
end

Instead of .Touched you could constantly check if the player’s position is inside the box/part

The issue with your script is in the logic of the if-else statements. The script is checking if the player’s current stage is less than the stage they just touched. If it is, it sets the player’s stage to the stage they just touched. However, if the player’s current stage is not less than the stage they just touched, it does not increment the player’s stage.

Here is my edited script:

for _, v in pairs(workspace.Stages:GetChildren()) do
	v.Touched:Connect(function(hit)
		if v and v.Parent == workspace.Stages then
			local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
			if plr then
				if Configurations.AnyCheckpoint then
					if plr.Character:WaitForChild("Humanoid").Health > 0 then
						if tonumber(v.Name) > plr.leaderstats.Stage.Value then
							plr.leaderstats.Stage.Value = tonumber(v.Name)
							plr.TStage.Value = plr.leaderstats.Stage.Value
						else
							plr.leaderstats.Stage.Value = plr.leaderstats.Stage.Value + 1
							plr.TStage.Value = plr.leaderstats.Stage.Value
						end
					end
				else
					if plr.Character:WaitForChild("Humanoid").Health > 0 then
						if plr.leaderstats.Stage.Value == tonumber(v.Name) - 1 then
							plr.leaderstats.Stage.Value = plr.leaderstats.Stage.Value + 1
							plr.TStage.Value = plr.leaderstats.Stage.Value
						elseif plr.TStage.Value < tonumber(v.Name) - 1 then
							plr.TStage.Value = plr.TStage.Value + 1
						end
					end
				end
			end
		end
	end)
end

In this script if the player’s current stage is not less than the stage they just touched, the player’s stage is incremented by 1. This ensures that the player’s stage always increases when they touch a checkpoint, regardless of whether the checkpoint’s stage is greater than the player’s current stage.

I hope I make myself understood, but the character I am using is not the real one, so to speak, I am using a copy of the character, because if I use the real character for some reason they are deleted, causing the game to break but the code you provide works

I already checked it and it’s still the same

I’ve also seen that when I try to use the actual character on the bike, when I get to a checkpoint it doesn’t add the stage anymore.