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 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)
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.
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 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.
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.