Help me! Prestige and Checkpoint System

Hi there!
I am trying to make an Obby (Mega Fun Obby (Beta) ) and i have been working on the prestige and the checkpoint systems lately. But i have this one error that whenever i prestige , i go back to the spawn area and then when i try to do the obby and get on the checkpoints, it doesn’t register the value of the ‘stage’ to the leaderstats. Please help me rectify the error

Here’s the video showing the error- robloxapp-20200513-1215366.wmv (2.9 MB)

Here is the script for the leaderstats and the checkpoints:

Leaderstats-

local DataStore = game:GetService("DataStoreService")
local ds1 = DataStore:GetDataStore("Level")
local ds2 = DataStore:GetDataStore("Prestige")

function oa(object)
local player = game.Players:playerFromCharacter(object)
if player ~= nil then
local ls = player.leaderstats
local sl = game.Workspace.Stages:FindFirstChild(ls.Stage.Value)
object.HumanoidRootPart.CFrame = object.HumanoidRootPart.CFrame + Vector3.new(0,3,0)
wait()
object.HumanoidRootPart.CFrame = sl.CFrame + Vector3.new(0,3,0)
end end
function oe(object)
if object.className == "Player" then
local leader = Instance.new("IntValue")
leader.Name = "leaderstats"
local Level = Instance.new("IntValue")
local Rebirth = Instance.new("IntValue")
Level.Name = "Stage"
Rebirth.Name = "Rebirths"
Level.Value = 1
Rebirth.Value = 0
Level.Parent = leader
Rebirth.Parent = leader
leader.Parent = object
end end

game.Players.ChildAdded:connect(oe)
game.Workspace.ChildAdded:connect(oa)
____````````_____________________________________
And the script for the checkpoints - 
```lua
script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if game.Players:FindFirstChild(hit.Parent.Name) then
			local Player = game.Players:FindFirstChild(hit.Parent.Name)
			local Stage = Player:WaitForChild("leaderstats"):WaitForChild("Stage")
			if Stage.Value == script.Parent.Name -1 then
				Stage.Value = script.Parent.Name
			end
		end
	end
end)

this is also my first post :smiley:

1 Like

Please format your code so I can properly help you, it’s very hard to read the code like this, to format your code follow these steps:

luaformat

And this is how it should look like for u:

theformat

Alright so now that you have formatted your code I can already see a mistake here, change this line to:

local player = game.Players:GetPlayerFromCharacter(object)

And tell me if it still doesn’t work, but first make sure you look at your output and tell me if there are any errors going on there about this script.

there is one error Stages is not a valid member of Workspace

Your getting this error because Stages doesn’t exist in the workspace, could you send me a screenshot showing your Workspace’s contents?

You can clearly see why it’s giving you that error, Stages is nowhere to be found in your Workspace based on your screenshots, I don’t know what “Stages” is supposed to be so add your Stages and then tell me if that fixes it.

i added a folder call “Stages” and it has all the checkpoints and it did fix the error but it didnt fix the error i asked

Could you please explain what you mean by this?

Do you mean that it did fix the previous error but now a new error has occured?

If that’s the case then what’s the new error?

i mean to say that it fixed the previous error which was the stages is not a valid member of workspace but not the checkpoint error

i dont think its the leaderstats script error, i think its because the Stage script only allows the player to step on it once and only add +1 to the stages in leaderstats. It is not scripted so that it allows the players to prestige and step on it to add 1 to the stages.

I can’t see everything, but I would guess that your 1st checkpoint is called “2”, but when you prestige,
you reset stage to 0, which means you’ll never get the transition because it needs to be a difference of
1 from your first checkpoint. When you hit Prestige, try resetting the stage to 1 instead of 0 and see if
it works.

i did try that but it didnt work

Put in some print() or warn() calls in various points in the code to see if listeners are called and/or values are what you expect they are at various points.

Well i added warn(1) in my checkpoint script and the output is correct

and after prestige the thing changed from the first time which was- robloxapp-20200513-1215366.wmv (2.9 MB)

and now its-robloxapp-20200515-1731553.wmv (1.6 MB)

So for instance, you could have stuff like:
print("Stage value:", Stage.Value)
print("Got to Touched Listener")
print("Got to get Stage:", Stage)
etc.

heres the output for the following-

Try changing print("Stage value:", Stage.Value) to
print("Stage value -->"..Stage.Value.."<--" )
and look at the output again.

yeah so after prestige also it says the stage value -->50<-- as shown in the output

So are you saying that that continues to show 50, but what you see on the leaderboard does not?