Checkpoint System

With a checkpoint system, how would I create a gui that displays a list of all of the players’ checkpoints they have reached, like steep steps for instance? For example, if the player has reached the 6th checkpoint and they click on the gui, it would display checkpoints 1-6, and when the player clicks any of the buttons, it would teleport them to the attributed checkpoint.

I created a text button and stored it in replicated storage, then used a for loop to get the number of checkpoints, then cloned it accordingly, but it was pretty janky.

Anyone have any ideas? Thanks.

3 Likes

I still need help. Can anyone help me?

3 Likes

could I probably see the system you made? How was it janky? I could probably help.

3 Likes

Could do this for example:

Workspace → Checkpoint → “Normal” Script

script.Parent.Touched:Connect(function(hit)
      if hit.Parent:IsA(“Model”) and hit.Parent:FindFirstChild(“HumanoidRootPart”) then
    game.Players:GetPlayerFromCharacter(hit.Parent).leaderstats.CHECKPOINT_VALUE.Value = script.Parent.Name
         end
    end

Idk if this works, it’s just an example :man_shrugging:

Then with something like that you’ll prolly be able to find out the rest easily (display the checkpoints from 1 to CHECKPOINT_VALUE or whatever you’re calling it).

2 Likes

Well I deleted it, but essentially I created a button within replicated storage, and then made a script that whenever the teleport button is clicked, it would use a for loop and get the player’s checkpoint value, and make a new button for every value, but I’m not sure how to change the button names to move to each checkpoint, or how to differentiate between all of the buttons.

1 Like

Well this wouldn’t necessarily work when the player rejoins, because they could be on stage 6, touch it, but it would only create one button. I don’t think this is the most efficient way, thanks for the attempt though. I appreciate it.

2 Likes

I’ll give it another shot cuz why not (kinda was lazy to write everything correctly:

local c_value = your_checkpoint_value

button.click:connect(func()
for i = 1, c_value do
-- I assume you have a UI layout in the GUI
local button = instance(“Button”)
button.Text = “Checkpoint “..i
button.Parent = theGUI
end
end)
2 Likes

This is a better approach. I will probably go off of this. Thanks.

2 Likes

i’m guessing you could create a GUI with a scrollingframe and have UIListLayout or UIGridLayout so the buttons are in order. And every time a player steps on a new checkpoint a remote is fired to their client that puts the button in said scrollingframe. You would name your checkpoints “Checkpoint 1” “Checkpoint 2” and so on. when the button is clicked their character position is set to what checkpoint number they clicked. You would need the name the buttons “1” “2” and so on though. I could attempt creating a example for you.

2 Likes

I think I got it from here, was just thinking about how to order them. I appreciate the help.

2 Likes

Alright, no problem. Good luck!

2 Likes

So A GUI with buttons, that when clicked, telelport them? Question also becomes if you want to hook this up to a datastore to save when the leave, and reload on rejoin.

I just made I checkpoint system myself so idc if I share my code with you

Here are my setup recommendations:

Make 2 folders, One for when the player touches this part, we will record them touching it, and the other folder, for the location the player will be teleported to. We will also add a Object, and a IntValue in the ‘player touches this part’ in the folder. Example:

Screenshot (2409)
(PS. the parts can be invisible and cancollide off if you don’t want the player to see them.)

Also Have a remote Event in rep. stroage. We will use this to teleport the player on the server, as well as a server script in server script service with this code:

game.ReplicatedStorage.TeleportPlayer.OnServerEvent:Connect(function(player, part)
	player.Character:PivotTo(part:GetPivot())
end)

image

I had this GUI set up

image

Then inside that local script I did this, and boom, it works:

local UnlockedCheckpoints = {}
local plr = game.Players.LocalPlayer

for i, v in game.Workspace.CheckpointTouchParts:GetChildren() do 
	if v:IsA("Part") then
		v.Touched:Connect(function(hit)
			if hit.Parent == plr.Character and table.find(UnlockedCheckpoints, v:FindFirstChildWhichIsA("IntValue").Value) == nil then 
				table.insert(UnlockedCheckpoints, v:FindFirstChildWhichIsA("IntValue").Value)
			end
		end)
	end
end




for i, v in script.Parent.CheckpointButtons:GetChildren() do 
	if v:IsA("TextButton") then
		v.MouseButton1Click:Connect(function()
			if table.find(UnlockedCheckpoints, v:FindFirstChildWhichIsA("IntValue").Value) then 
				local PosPart = nil 
				for i, TouchParts in game.Workspace.CheckpointTouchParts:GetChildren() do 
					if TouchParts:IsA("Part") and v:FindFirstChildWhichIsA("IntValue").Value == TouchParts:FindFirstChildWhichIsA("IntValue").Value then
						PosPart = TouchParts:FindFirstChildWhichIsA("ObjectValue").Value
					end
				end
				if PosPart == nil then 
					error("No Position Part Found")
				else
					game.ReplicatedStorage.TeleportPlayer:FireServer(PosPart)
				end
			end
		end)
	end
end

Hope this helps and lmk if you have questions!

I’ll look into this. This helps a lot. Thanks.

1 Like

Make GUI buttons maybe using UIListLayout or whatever you wish.
Name the buttons corresponding to the checkpoint no.
Make a new RemoteEvent inside ReplicatedStorage called “Teleport”

Then if you have a checkpoints folder, use this LocalScript for GUI -

local ScreenGUI = script.Parent --assuming
local player = game.Players.LocalPlayer

for _, button in pairs(ScreenGUI:GetChildren()) do
if v:IsA("TextButton") then
button.MouseButton1Down:Connect(function()
if player.leaderstats.Whatever.Value >= tonumber(button.Name) then
game.ReplicatedStorage.Teleport:FireServer(button.Name)
end
end)
end
end

Now for the teleport script -

game.ReplicatedStorage.Teleport.OnServerEvent:Connect(function(player, stage)
player.leaderstats.Whatever.Value = stage
player:LoadCharacter()
end)

This is how I do.

This seems to be the normal teleport code. But wouldn’t it just update to client and not the server? Because this is a LocalScript I guess

I see. Thanks a lot for the help. I appreciate it.

1 Like

Well so there is a table that updates for the client. For me, I had a lock icon, so the table was hooked to the table for locking and unlocking the buttons so it made sense for them to be stored on the client. But yes you could store it on the server.

The client also just checks that very table on clicking the button to check if they can teleport as well.

2 Likes