How do I convert these scripts to R6?

Thanks for that, forgot to take it out when I tested it and wrote the side note.

1 Like

You can temporarily (or permanently) set every player to R15 in the game settings.

Hello, thank you for helping me. When I tested the script, everything worked normally, although nothing assures me that the error has stopped, since so far nobody has informed me again about the error, although it was only 20min since I posted it. Another thing, do you have any idea why when entering the game, the players don’t appear in their corresponding level and must first die somehow to appear again? As I say, this doesn’t happen if the game character is at R15, but my characters are at R6.

I honestly can’t say for certain what is causing this bug, but as I said using the torso to teleport R6 rigs has sort of fixed this in the past. The only other thing I can possibly think of is that the R6 rig loads faster than the stages (less parts to load than an R15 rig) and it can’t find the stage in time to teleport the player.

With this in mind, try changing:

local part = workspace.ObbyStages:FindFirstChild(stage.Value)

to:

local part = workspace.ObbyStages:WaitForChild(stage.Value)

It hasn’t worked, it’s still the same. And I agree with you, since as I say I use a SpawnLocation and that surely loads faster and doesn’t let the player go to his corresponding level. Do you have any idea how to remove the SpawnLocation and change it for a normal piece? All this without the current players level being reset. Anyway thank you very much for your help!!!

So, it turns out I’ve actually helped someone with a similar problem not so long ago, except it was caused by something else. Here is the link to the post: How fix problem in obby

The script he used is different but achieves the same thing, it may be worth going through.

In his script to teleport a player he used:

local sl = game.Workspace.Checkpoints:FindFirstChild(ls.Stage.Value)
wait(2)
object.Torso.CFrame = object.Torso.CFrame + Vector3.new(0,3,0) -- object is the character
object.Torso.CFrame = sl.CFrame + Vector3.new(0,3,0)

Similar to what you did except he waited 2 seconds and did an extra “teleport” (to move the character upwards, again don’t think it would make a difference but seems to work for him).

Below is a slightly modified version of your script using what I mentioned before and above.

Script
local player = game:GetService("Players")
local dataStoreService = game:GetService("DataStoreService")
local saveDataStore = dataStoreService:GetDataStore("SaveDataTest")

local function savePlrData(plr)

	local success,err = pcall(function()

		local saveData = {}

		for _,stat in pairs(plr.leaderstats:GetChildren())do

			saveData[stat.Name] = stat.Value

		end

		saveDataStore:SetAsync(plr.UserId,saveData)

	end)

	if not success then return err end

end

player.PlayerAdded:connect(function(plr)
   plr.CharacterAdded:connect(function(char)
	local stats = Instance.new("Folder")
	stats.Name = "leaderstats"
	stats.Parent = plr

	local stage = Instance.new("IntValue")
	stage.Name = "Stage"
	stage.Parent = stats

	local data = saveDataStore:GetAsync(plr.UserId)

	if data then

		print(data.Stage)

		for _,stat in pairs(stats:GetChildren()) do

			stat.Value = data[stat.Name]

		end

	else

		print(plr.Name .. " has no data")

	end

		local humanoid,hrp = char:WaitForChild("Humanoid"), char:WaitForChild("HumanoidRootPart")

		wait()

		if humanoid and hrp then

			if stage.Value ~= 0 then
                                
				local part = workspace.ObbyStages:WaitForChild(stage.Value)
                wait(2)
                char.Torso.CFrame = char.Torso.CFrame + Vector3.new(0,3,0)
				char.Torso.CFrame = part.CFrame + Vector3.new(0,3,0)

			end

		end

	end)

end)

player.PlayerRemoving:connect(function(plr)

	local err = savePlrData(plr)

	if err then print(err) end

end)

game:BindToClose(function()

	for _,plr in pairs(player:GetPlayers()) do

		local err = savePlrData(plr)

		if err then print(err) end

	end


end)

Edit: With regards to the SpawnLocation, there is no need to get rid of it, if anything it’s easier to have one as a starting area. If you want faster respawn times you can just set the RespawnTime to 0.

Ok, the script worked correctly, and rather reminded me of something. Some time ago I created a similar post and the script I was given solved the problem but when I died it appeared 1 second at the start before returning to my corresponding level, I remember that when I asked the player who helped me if I could avoid that waiting time, he never answered me. Now that I see, it seems to be the same script or similar, that’s why I would like to ask him if there is any way to avoid that waiting time before returning to the level. Thanks anyway

Okay, I think I have a fix for that wait time. Basically you can get rid of the SpawnLocation, and instead if Stage.Value == 0, you just set the CFrame to where stage 0 is.

Here is a quick example of what I did:

Example
game.Players.PlayerAdded:Connect(function(player)
	local location = game.Workspace:WaitForChild("View3")
	player.CharacterAdded:Connect(function(char)
		wait()
		local place = location.CFrame + Vector3.new(0,3,0)
		char:SetPrimaryPartCFrame(place)
	end)
end)

In this example I used SetPrimaryPartCFrame instead of waiting for the HumanoidRootPart or Torso, either method works, and make sure you find the location you want to teleport to before the character is added. Lastly, you need to have that wait() or it just does not work.

I do not understand anything. Don’t worry, you surely explained it well and the fool here is me. I don’t know if you could make me that script, and of course I can give you 50 robux if you want. I would like what replaces the SpawnLocation to be a piece called “0” which is in a folder called “ObbyStages”. In case you accept, the payment would be for a GamePass that you should price 71 robux, if you don’t want to do it by GamePass, I can do it by group, but it would take 2 weeks before I can share funds with you because Roblox has a system that doesn’t allow to give robux to newly joined users.

image

No need for payment.

Made slight alterations to your script:

Script
local players = game:GetService("Players")
local dataStoreService = game:GetService("DataStoreService")
local saveDataStore = dataStoreService:GetDataStore("SaveDataTest")

local function savePlrData(plr)
	local success,err = pcall(function()
		local saveData = {}
		for _,stat in pairs(plr.leaderstats:GetChildren())do
			saveData[stat.Name] = stat.Value
		end
		saveDataStore:SetAsync(plr.UserId,saveData)
	end)
	if not success then return err end
end

players.PlayerAdded:connect(function(plr)
	local stats = Instance.new("Folder")
	stats.Name = "leaderstats"
	stats.Parent = plr

	local stage = Instance.new("IntValue")
	stage.Name = "Stage"
	stage.Parent = stats

	local data = saveDataStore:GetAsync(plr.UserId)
	if data then
		print(data.Stage)
		for _,stat in pairs(stats:GetChildren()) do
			stat.Value = data[stat.Name]
		end
	else
		print(plr.Name .. " has no data")
	end
	
	local part = workspace.ObbyStages:WaitForChild(stage.Value)
	local start = workspace.ObbyStages:WaitForChild("0")
    plr.CharacterAdded:connect(function(char)
		wait()
		if stage.Value == 0 then     
			local destination = start.CFrame + Vector3.new(0,3,0)
			char:SetPrimaryPartCFrame(destination)
			--char.Torso.CFrame = destination Note: Comment out should SetPrimaryPartCFrame not work
		else
			local destination = part.CFrame + Vector3.new(0,3,0)
			char:SetPrimaryPartCFrame(destination)
			--char.Torso.CFrame = destination Note: Comment out should SetPrimaryPartCFrame not work
		end
	end)
end)

players.PlayerRemoving:connect(function(plr)
	local err = savePlrData(plr)
	if err then print(err) end
end)

game:BindToClose(function()
	for _,plr in pairs(player:GetPlayers()) do
		local err = savePlrData(plr)
		if err then print(err) end
	end
end)

If you run into any problems let me know. Don’t forget to remove the SpawnLocation.

Edit: just changed a line and added new line that should fix a bug I think may occur. Try both scripts though

Updated Script
local players = game:GetService("Players")
local dataStoreService = game:GetService("DataStoreService")
local saveDataStore = dataStoreService:GetDataStore("SaveDataTest")

local function savePlrData(plr)
	local success,err = pcall(function()
		local saveData = {}
		for _,stat in pairs(plr.leaderstats:GetChildren())do
			saveData[stat.Name] = stat.Value
		end
		saveDataStore:SetAsync(plr.UserId,saveData)
	end)
	if not success then return err end
end

players.PlayerAdded:connect(function(plr)
	local stats = Instance.new("Folder")
	stats.Name = "leaderstats"
	stats.Parent = plr

	local stage = Instance.new("IntValue")
	stage.Name = "Stage"
	stage.Parent = stats

	local data = saveDataStore:GetAsync(plr.UserId)
	if data then
		print(data.Stage)
		for _,stat in pairs(stats:GetChildren()) do
			stat.Value = data[stat.Name]
		end
	else
		print(plr.Name .. " has no data")
	end
	
	wait(workspace.ObbyStages:WaitForChild(stage.Value))
	local start = workspace.ObbyStages:WaitForChild("0")
    plr.CharacterAdded:connect(function(char)
		wait()
		local part = workspace.ObbyStages:FindFirstChild(stage.Value)
		if stage.Value == 0 then     
			local destination = start.CFrame + Vector3.new(0,3,0)
			char:SetPrimaryPartCFrame(destination)
			--char.Torso.CFrame = destination Note: Remove comment should SetPrimaryPartCFrame not work
		else
			local destination = part.CFrame + Vector3.new(0,3,0)
			char:SetPrimaryPartCFrame(destination)
			--char.Torso.CFrame = destination Note: Remove comment should SetPrimaryPartCFrame not work
		end
	end)
end)

players.PlayerRemoving:connect(function(plr)
	local err = savePlrData(plr)
	if err then print(err) end
end)

game:BindToClose(function()
	for _,plr in pairs(players:GetPlayers()) do
		local err = savePlrData(plr)
		if err then print(err) end
	end
end)

First of all, I would like to thank again for the help. Now, none of the scripts worked, the player appears in nothingness and only when he dies he appears in his level.

Now, I noticed that in your script there is this:


Should I write something in “destination”? Sorry, I don’t understand

And more
image
I noticed that at the end of your script, there seems to be an error, as there is a blue line below a script. I’m not sure but I’ll report it to you anyway

Edit: Don’t forget that there is another script besides that one, maybe the error is in the other one.

Change player to players.

In the video your character does not die, but gets teleported before dying. The wait is a still there it seems, comment out wait(workspace.ObbyStages:WaitForChild(stage.Value)) and see if that solves it.

1 Like

I do not understand. I’m really sorry, but I speak Spanish

image

Put -- in-front of the line: Comments | Roblox Creator Documentation

--wait(workspace.ObbyStages:WaitForChild(stage.Value))

Edit: I don’t think that would actually solve it rather try this:
In Players, set RespawnTime to 0 and Disable CharacterAutoLoads and use the following script.

Script
local players = game:GetService("Players")
local dataStoreService = game:GetService("DataStoreService")
local saveDataStore = dataStoreService:GetDataStore("SaveDataTest")

local function savePlrData(plr)
	local success,err = pcall(function()
		local saveData = {}
		for _,stat in pairs(plr.leaderstats:GetChildren())do
			saveData[stat.Name] = stat.Value
		end
		saveDataStore:SetAsync(plr.UserId,saveData)
	end)
	if not success then return err end
end

players.PlayerAdded:connect(function(plr)
	local stats = Instance.new("Folder")
	stats.Name = "leaderstats"
	stats.Parent = plr

	local stage = Instance.new("IntValue")
	stage.Name = "Stage"
	stage.Parent = stats

	local data = saveDataStore:GetAsync(plr.UserId)
	if data then
		print(data.Stage)
		for _,stat in pairs(stats:GetChildren()) do
			stat.Value = data[stat.Name]
		end
	else
		print(plr.Name .. " has no data")
	end
	
	wait(workspace.ObbyStages:WaitForChild(stage.Value))
	local start = workspace.ObbyStages:WaitForChild("0")
    plr.CharacterAdded:connect(function(char)
		wait()
		if stage.Value == 0 then     
			local destination = start.CFrame + Vector3.new(0,3,0)
			char:SetPrimaryPartCFrame(destination)
		else
		    local part = workspace.ObbyStages:FindFirstChild(stage.Value)
			local destination = part.CFrame + Vector3.new(0,3,0)
			char:SetPrimaryPartCFrame(destination)
		end
		
		char.Humanoid.Died:Connect(function()
			plr:LoadCharacter()
		end)
	end)
	plr:LoadCharacter()
end)

players.PlayerRemoving:connect(function(plr)
	local err = savePlrData(plr)
	if err then print(err) end
end)

game:BindToClose(function()
	for _,plr in pairs(players:GetPlayers()) do
		local err = savePlrData(plr)
		if err then print(err) end
	end
end)
2 Likes

Hi, the script was already working fine but the levels are not being counted. I created a new account to get into parkour but when I move to the next level it doesn’t go up in the leaderboard and neither does the position I was in.

(On my account where I am at level 200, the level is still the same, but it does not let me move to the next level).

1 Like

I’ve changed nothing in the script that should affect levels, and the plrHandler (the script I edited) does not count the levels, the ObbyHandler does.

1 Like

Hello, I have already realized the error and it was that the level 1 was in another folder different from ObbyStages, now I’m back to the topic… THANK YOU VERY MUCH for helping me, the script has worked correctly and everything seems normal. I only have 3 doubts.

  1. What do you think caused the players to have their Parkour level reset?
  2. In the following video, if you look closely, you can see that when I die I appear for 1 millisecond in the air, and then I just appear in my level. Do you know how to remove that or what causes it?
  3. Is there any way that when I die I don’t immediately reappear in my level? For example, I would like that when I die it takes 0.5 seconds to reappear and that it is not immediate.

Don’t worry, even if you can’t give me any solution or answer to these 3 questions, I will give you the credits as “solved” in this topic. Since the main thing was how to solve the level reset problem and have the players appear in their level without having to die first, and apparently you solved it, since I don’t see any problem with the script.

EDIT: I would care more to know how I make it so that players take 0.5 seconds to respawn and not immediately.

1 Like
  1. What do you think caused the players to have their Parkour level reset?
  1. Not entirely sure, might be that their levels did not save properly when they left. Might be a good idea to implement an auto save feature (maybe save the data every minute or two)
  1. In the following video, if you look closely, you can see that when I die I appear for 1 millisecond in the air, and then I just appear in my level. Do you know how to remove that or what causes it?
  1. That is supposed to happen, your character loads and since there is no spawn location you load mid air and then get teleported to your stage.
  1. Is there any way that when I die I don’t immediately reappear in my level? For example, I would like that when I die it takes 0.5 seconds to reappear and that it is not immediate.

Change:

char.Humanoid.Died:Connect(function()
     plr:LoadCharacter()
end)

to:

char.Humanoid.Died:Connect(function()
     wait(0.5)
	 plr:LoadCharacter()
end)

But then, the script I have doesn’t have that automatic save every 2min, so how often is the progress of the players saved in this script you gave me?

Oh I understand, I just saw that other parkours didn’t have that problem, but it’s not such a big problem.

Thanks, it worked correctly

1 Like

But then, the script I have doesn’t have that automatic save every 2min, so how often is the progress of the players saved in this script you gave me?

It only saves when the player leaves. If you want to save player data every minute, just add:

local save = coroutine.create(function()
    while wait(60) do
      savePlrData(plr)
    end
end)
coroutine.resume(save)

You should put this under:

    end)
	plr:LoadCharacter()