Help with skip stage for the obby I'm working on with my friend

@NinjaMinion101. It works now, but I can’t seem to be able to get the character to teleport to the next stage

1 Like

Hi, I’m glad you managed to make the purchase work. Great job! :slight_smile:
The character needs to teleport to the next stage: let’s see what the problem is.

player.Character.HumanoidRootPart.CFrame = "stage block name" 

Okay! so the script probably doesn’t understand what ‘‘stage block name’’ is.
‘‘stage block name’’ needs to be replaced with the checkpoint the player needs to teleport to.

How can the script know what checkpoint the player teleports to?
First, the script needs to know what stagenumber the player needs to teleport to:

local newstagenumber = player.leaderstats.Stage.Value + 1

Now we know what stagenumber the player teleports to, we need to know what checkpoint is goes along with that stage (the checkpoint the player is going to teleport to).

local checkpoint = game.Workspace:FindFirstChild(newstagenumber)

So what happens here is: the script is searching through the workspace for a part named newstagenumber (and newstagenumber is a number like 10, or 11…depends).

One thing you need to note is that I assume your checkpoints are named like the number of the stage AND that the checkpoints are found directly in the workspace (because game.Workspace)

Now, we adjust the line you had made before. The CFrame of the HumanoidRootPart of the player is equal to the CFrame of ‘‘checkpoint’’ (the location of the new checkpoint).

player.Character.HumanoidRootPart.CFrame = checkpoint.CFrame

Got it? I hope it was understandable! If not, feel free to ask questions. This is the end result:

local newstagenumber = player.leaderstats.Stage.Value + 1
local checkpoint = game.Workspace:FindFirstChild(stagenumber)

player.Character.HumanoidRootPart.CFrame = checkpoint.CFrame

Thanks! Although I’m currently watching a tutorial on utube, if it doesn’t work, I’ll do what you’re suggesting

Good luck! I hope you understand the idea behind the script now.

P.s. instead of teleporting the player to the new checkpoint, you can also kill the player: much easier. Because the value is already changed.

You’re right! How did I not come up with that from the start!?

1 Like

Make sure to add wait() between the ‘’ Value + 1 ‘’ and the ‘’ Kill player ‘’ line, to make sure nothing goes wrong when someone is spending robux.

Well, as I said, I’m currently watching a video on YouTube about this (In Spanish so if the code doesn’t work I will come back with it in this post. There are words like: numero, etc)

1 Like

Ummm :thinking:, actually my checkpoints are called spawn location.
And also, I’m smart enough to know that I have to put game.Workspace.Checkpoint:FindFirstChild() instead of just game.Workspace

I’ll send a pic of the explorer so you can see how I have stuff organized

Workspace

image

don’t mind puntonivelcompra

Workspace > Checkpoints

image

StarterGUI

image

StarterGUI > ScreenSkipStage

image

StarterGUI > ScreenSkipStage > LocalScript
local MPS = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer repeat wait() until player

local button = script.Parent.Button

local id = 1247673078


local frameEfecto = script.Parent.FrameEfecto


button.MouseButton1Click:Connect(function()
	MPS:PromptProductPurchase(player, id)
end)

local function compraFinalizada(userId, compraId, compraExitosa)
	local character = player.Character
	local numero = character.Contador.Value + 1
	
	if numero > #game.Workspace.PuntoNivelCompra.PuntosNiveles:GetChildren() then
		
	end
	
	
	
end

--continue watching: https://www.youtube.com/watch?v=fuYgP0zXwqA

(that’s what i have so-far in the script)

Teams

image

Ah okay. Well, a solution would be to name your checkpoints the number of the stage. If that is not possible for a reason, you have to find another way to teleport the player to the correct checkpoint.

What is the part for in the model ‘‘checkpoint’’ in workspace?

Yes, the tutorial on yt says to put a part on top of the checkpoints, that’s what is stored in PuntoNivelCompra.

It’s the grass baseplate holding the checkpoint pad

Oh! So if I see this correctly, you work with ‘‘teams’’ for each stage. In that case, you can add the player who made the purchase to the new team (the team named ‘‘stage x’’ → x needs to be the same value as the player’s value after the purchase).

Ok so instead of using models for each checkpoint, u can create a Folder called Checkpoints and just add a part for each checkpoint and name it the stage number

1 Like

Yep, exactly what the video told me :slight_smile:

Definitely! This is a great solution to the problem.

No, I never said that. Or atleast I don’t remember saying that…

i replied to the wrong post lol, i meant to reply to this one