Obby Checkpoint Script Not Working

I hired a Dev to make me an obby but he screwed up a lot. Especially with the checkpoints. The checkpoint script saves your stage but on the leaderboard it constantly says “Stage 1”. Here is the script I used:

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)

I only started scripting a few days ago so I don’t know what’s wrong with the script. Does anyone know?
Please help because when I asked him he demanded Robux to fix all the mistakes he made, and he asked for a LOT.

No where in that code does it add any sort of thing to leaderstats.

You need to add that code to the script.

1 Like

It constantly says Stage 1 because there’s no code that is meant to update the value in the code you’ve provided. Is the name of your checkpoints a number? You can do

player.leaderstats.Checkpoint.Value = "Stage ".. tostring(spawn.Name)

After setting the value of checkpoint

Replace Checkpoint with the name of your leaderstat value

Edit: Also the code needs a lot of improvement from what I can tell, especially since it looks like CheckpointData and CheckPointValues are not made automatically and that it will create a new event for CharacterAdded everytime a checkpoint has been stepped on, although I could be wrong on that last one

1 Like

So is this right?

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
		
		player.leaderstats.Checkpoint.Value = "Stage ".. tostring(spawn.Name)
	end
end)

Yes, but where is checkpoint.Value = spawn? I didn’t say to remove it. Also my example will only work if the name of the checkpoint is a number, like I already said

I don’t know the first thing about scripting to be honest, so I don’t know where to put it.

Undo so your code is back to how it was when you sent it, and put the line that I mentioned after checkpoint.Value = spawn

Ok last question. Do I put it on the line underneath it or just put a space and put it on the same line as checkpoint.Value = spawn

You put it underneath checkpoint.Value = spawn

Ok thank you so much! You’re a legend!

1 Like

Anytime, there may be some problem that may occur when trying this, but it shouldn’t be that problematic to fix. If needed, I could also come over there to fix what your developer wont if needed, I’ll even do it for free since you’re saying he wants way too much robux to fix his mistakes

1 Like

That would be great! Whenever I play in Studio it doesn’t even show the Stage thing on the leaderboard so I always have to publish it. Also there’s this GUI shop thing he put on screen and I can’t find it in explorer so I can’t configure it or delete it. I have my own (working) in game shop [gamepasses] but the one he put in doesn’t even work and it doesn’t show up in Studio, only when you play the game. Here’s a link to the game: Ultra Parkour Obby [BETA] - Roblox My shop is the blue one with the speed coil and gravity coil and his is the other one. Is there any way of removing it?

You could try searching in the Explorer for any ScreenGuis that you don’t recall making and seeing if removing them would do the trick. Shall we continue in Messages so we don’t fill this now solved post?

image That’s what comes up. Those are all of my GUIs so I don’t know where to find his.