Hello I have a Parkour game where your level is saved, that is, if you exit the game your level will continue to be saved so that you can continue playing one more day. But a problem happens, is that many people have complained that when they are at a high level, their level is reset and takes them to the beginning. I think this could be a problem with the scripts as it is an old script and maybe it no longer works properly, so I would like you to update these scripts to a more modern way, I donât know if this solves anything. but I want to
When was this made?
I donât really see any issues, it could be a problem with the datastores as it is not getting data as it is SUPPOSED to, or it could be a problem with saving, but when looking at the code there is nothing wrong.
I recommend making a backup datastore, so that peopleâs data are saved periodically to prevent data loss.
And then try to get data via backup, if that does not work then you have a clear issue of data loss.
Was It when the player joined they where back at stage 1, That would be the 2th script.
If it was when the player like stepped on a check point and the stats where back at 0, then that would be the first script.
Also, if you donât know, Hereâs a updated script for the first one:
local obbyStages = workspace:WaitForChild("ObbyStages")
for _,stage in pairs(obbyStages:GetChildren()) do
stage.Touched:connect(function(hit)
local hum
if hit.Parent:FindFirstChild("Humanoid") then
hum = hit.Parent.Humanoid
end
if hit.Parent and hit.Parent.Parent:FindFirstChild("Humanoid") then
hum = hit.Parent.Parent.Humanoid
end
if hum then
local plr = game.Players:GetPlayerFromCharacter(hum.Parent)
local plrStage = plr.leaderstats.Stage.Value
if tonumber(stage.Name) == plrStage + 1 then
plr.leaderstats.Stage.Value = plr.leaderstats.Stage.Value + 1
elseif tonumber(stage.Name) > plrStage + 1 then
hum.Health = 0
end
-- Save Guard:
if tonumber(stage.Name) ~= plrStage + 1 then
plr.leaderstats.Stage.Value = tonumber(stage.Name) +1
end
end
end)
end
if hit.Parent and hit.Parent.Parent:FindFirstChild("Humanoid") then
hum = hit.Parent.Parent.Humanoid
end
if hum then
local plr = game.Players:GetPlayerFromCharacter(hum.Parent)
local plrStage = plr.leaderstats.Stage.Value
if tonumber(stage.Name) == plrStage + 1 then
plr.leaderstats.Stage.Value = plr.leaderstats.Stage.Value + 1
elseif tonumber(stage.Name) > plrStage + 1 then
hum.Health = 0
end
end
end)
end
In the script above, I added a save guard so then would not lose there data.
Hope this helped
Hello!!! Excuse me but why does the script come out like this, it seems like it was misspelled
Did you add the for loop?
That it where the âstageâ variable come from.
Then I have it in my script, it looks like this:
Yes, the whole script is complete, it also does not work when I tested it in the game. What I can do?
I see something wrong,
I just want to say it will take my a bot to fix, so give me a sec.
@valentino7754, The script was duplicated.
This may work:
local obbyStages = workspace:WaitForChild("ObbyStages")
for _,stage in pairs(obbyStages:GetChildren()) do
stage.Touched:connect(function(hit)
local hum
if hit.Parent:FindFirstChild("Humanoid") then
hum = hit.Parent.Humanoid
end
if hit.Parent and hit.Parent.Parent:FindFirstChild("Humanoid") then
hum = hit.Parent.Parent.Humanoid
end
if hum then
local plr = game.Players:GetPlayerFromCharacter(hum.Parent)
local plrStage = plr.leaderstats.Stage.Value
if tonumber(stage.Name) == plrStage + 1 then
plr.leaderstats.Stage.Value = plr.leaderstats.Stage.Value + 1
elseif tonumber(stage.Name) > plrStage + 1 then
hum.Health = 0
end
-- Save Guard:
if tonumber(stage.Name) ~= plrStage + 1 then
plr.leaderstats.Stage.Value = tonumber(stage.Name) +1
end
end
end)
end
When i addâŚ
-- Save Guard:
if tonumber(stage.Name) ~= plrStage + 1 then
plr.leaderstats.Stage.Value = tonumber(stage.Name) +1
end
end
end)
âŚthe script stops working and when I touch the next checkpoint it does not add the number in the leaderboard
ok, let me look more into this.
Wait, I donât thing you got the full script, here is it all, a end was out of the box:
local obbyStages = workspace:WaitForChild("ObbyStages")
for _,stage in pairs(obbyStages:GetChildren()) do
stage.Touched:connect(function(hit)
local hum
if hit.Parent:FindFirstChild("Humanoid") then
hum = hit.Parent.Humanoid
end
if hit.Parent and hit.Parent.Parent:FindFirstChild("Humanoid") then
hum = hit.Parent.Parent.Humanoid
end
if hum then
local plr = game.Players:GetPlayerFromCharacter(hum.Parent)
local plrStage = plr.leaderstats.Stage.Value
if tonumber(stage.Name) == plrStage + 1 then
plr.leaderstats.Stage.Value = plr.leaderstats.Stage.Value + 1
elseif tonumber(stage.Name) > plrStage + 1 then
hum.Health = 0
end
-- Save Guard:
if tonumber(stage.Name) ~= plrStage + 1 then
plr.leaderstats.Stage.Value = tonumber(stage.Name) +1
end
end
end)
end
the script works fine but for some reason when I touch the first level it raises me 2 levels instead of one
Excuse me this is very wrong, there are too many glitches in your script, for example: I am at checkpoint 20, but if I touch checkpoint 12, the system returns me to level 12, which shouldnât happen.
Another thing, it is assumed that if you skip a level you must die, that is, if you do not pass the levels in numerical order, the system must kill you, for example, the system will not let you skip levels, you must complete them all. But now that no longer happens, since I put the script that told me
just those problems and thatâs it
Last script coming in a min
@valentino7754, I think this will be it:
local obbyStages = workspace:WaitForChild(âObbyStagesâ)
for _,stage in pairs(obbyStages:GetChildren()) do
stage.Touched:connect(function(hit)
local hum
if hit.Parent:FindFirstChild("Humanoid") then
hum = hit.Parent.Humanoid
end
if hit.Parent and hit.Parent.Parent:FindFirstChild("Humanoid") then
hum = hit.Parent.Parent.Humanoid
end
if hum then
local plr = game.Players:GetPlayerFromCharacter(hum.Parent)
local plrStage = plr.leaderstats.Stage.Value
if tonumber(stage.Name) == plrStage + 1 then
plr.leaderstats.Stage.Value = plr.leaderstats.Stage.Value + 1
elseif tonumber(stage.Name) > plrStage + 1 then
hum.Health = 0
end
-- Save Guard:
if tonumber(stage.Name) ~= plrStage then
plr.leaderstats.Stage.Value = tonumber(stage.Name) +1
end
end
end)
end
Hello, the truth did not change much, just another problem arose, now I can only pass the levels two by two. But I canât complain, you are doing your best to help me, but I am only reporting the errors your scripts are having. I will give you another detail, the respawn point is not a block with the name â1â, if it is not a âSpawnLocationâ. I donât know why Iâm telling you this, but maybe it will help.
Umm, try this:
for _,stage in pairs(obbyStages:GetChildren()) do
stage.Touched:connect(function(hit)
local hum
if hit.Parent:FindFirstChild("Humanoid") then
hum = hit.Parent.Humanoid
end
if hit.Parent and hit.Parent.Parent:FindFirstChild("Humanoid") then
hum = hit.Parent.Parent.Humanoid
end
if hum then
local plr = game.Players:GetPlayerFromCharacter(hum.Parent)
local plrStage = plr.leaderstats.Stage.Value
if tonumber(stage.Name) == plrStage + 1 then
plr.leaderstats.Stage.Value = plr.leaderstats.Stage.Value + 1
elseif tonumber(stage.Name) > plrStage + 1 then
hum.Health = 0
end
end
end)
end
(I removed the safe gurad, this just may work )