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 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.
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
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)
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
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)
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”.