[OBBY CHECKPOINT] Could this work?

I haven’t written the script yet, but could this work for an obby checkpoint system;

An int value is stored in the player, and when the checkpoint is touched (with part.Touched) the players’ int value is set to the value of the checkpoint (first - 1, second - 2, etc.) then when the player is dead (or joins) the it checks for what the int value is (if Player.leaderstats.Checkpoint = 1 then) and sets the players’ respawn/spawn point to the object. I feel it would be a very simple way to make a checkpoint system, and it would be very easy to store the data and reload it when the player joins.

I really hope this would work :smile:

1 Like

I suggest using tables for this kind of stuff (especially when you use datastore), your method will work but it needs changes / checks. An exploiter could easily teleport to last checkpoint and that’s it, he finished whole obby.

1 Like

Yeah, I realized that when I came up with the idea. However, if an exploiter really wanted to teleport to the end of the obby, it does not affect the gameplay of others much, and the exploiter just won’t have fun, so really it’s worthless to teleport to the end

Player.RespawnLocation = Checkpoints[Level].Position

but, you have to keep in mind, you don’t want someone to accidentally touch the part from a previous level, so you gotta make a change in the script. You can use:

local Req = (what level it is)
script.Parent.Touched:Connect(function(plr)
if hit.Parent:FindFirstChild("Humanoid") then
    local player = plr.Parent:GetPlayerFromCharacter()
    local Stats = player:FindFirstChild("yourstatname")
    if Stats ~= nil then
        local Level = Stats:WaitForChild("Yourlevelname")
        if Level ~= nil
            if Level.Value = Req - 1 then
                Level.Value = Req
            end
        end
    end
end)

this script will prevent hackers from teleporting to the end, because of this line:
if Level.Value = Req - 1 then
that line means that you can only go to the level by completing the previous level, preventing hackers from teleporting to the end.

You should also put a detection script that detects if the level value is equal to a certain amount where the end is(in this case, it would be the number of levels in your game)

Edit: added humanoid detection, sorry about that

That’s not how it works though?
Touched doesn’t return the player, it returns the part that touched the object

sorry, my pc and internet is a bit buggy today, so some things didn’t register when I typed it in

Here’s an example I made for you, uncopylocked.

If you don’t understand something, ask me. Yes I know, it’s bad scripted, I scripted it in a hurry.

Edit: I also made an anti exploit for it, kind of .
https://gyazo.com/1add9b9476abe087d6c9ec329656a132
Execute in DevConsole

local p = game.Players.PLAYERNAME
local stages = 6
for i = 1, stages do 
	local w = workspace.Checkpoints[i]
	p.Character:SetPrimaryPartCFrame(w.CFrame)
	wait(.5)
end
1 Like

Other than verifying that touching part that touched the checkpoint is child of the character he did get player correctly.

He edited it, and it’s still incorrect, he doesn’t check for any humanoids so if something touches it other than a player will make the script error

So how could I implement this into my own game?

Check ServerScriptService, there’s a script called “Main”, copy that into your ServerScriptService
Now make a folder in workspace called ‘Checkpoints’ and add your Checkpoints there and rename them like the stage… ex 1 - stage one, 2 - stage three (check workspace so u can see what I mean)

That’s all, if you want to make it save, you should look into Data Stores | Documentation - Roblox Creator Hub

I changed it now, hopefully that works, I’m a bit tired today, and I’m a bit sick, so I kind of forgot about it.

I know how to save data using int values, but I can’t get it to work with the script you wrote. Here is the datastore script I am trying to use;

Script
local DSS = game:GetService("DataStoreService")

local DataStore = DSS:GetDataStore("Data")

game.Players.PlayerAdded:Connect(function(Player)

local Stage

local success,errormessage = pcall(function()

playerStage = DataStore:GetAsync(Player.UserId.."-Stage")

end)

if success then

Stage.Value = playerStage

else

print("There was an error while saving")

warn(errormessage)

end

end)

game.Players.PlayerRemoving:Connect(function(player)

local success, errormessage = pcall(function()

DataStore:SetAsync(player.UserId.."-Stage",player.leaderstats.Stage.Value)

end)

if success then

print("Plauer Data saved successfully")

else

print("error when saving data")

warn(errormessage)

end

end)
Error in Output
[01:04:03.519 - ServerScriptService.Script:11: attempt to index local 'Stage' (a nil value)

01:04:03.519 - Stack Begin

[01:04:03.519 - Script 'ServerScriptService.Script', Line 11
01:04:03.520 - Stack End

[01:04:04.153 - KRONOS: Loading .

I’ve edited the place with your code and fixed it.
I hope you understand that my code is written badly and you shouldn’t really follow that style “in a hurry”.

I suggest using this module for saving data

Good luck!

With that new code I am getting an error on line 91 and line 16… I can’t figure out how to fix the problem