When I enter the game, I appear at the beginning, when I press reset, I appear at stage 19.
-- :3
--DataStore--
local ds = game:GetService("DataStoreService"):GetDataStore("StatsStore4")
game.Players.PlayerAdded:Connect(function(player)
print("connected")
local playerFolder = Instance.new("Folder")
playerFolder.Name = "leaderstats"
playerFolder.Parent = player
local ack2 = Instance.new("IntValue")
ack2.Name = "Stage"
ack2.Value = 1
ack2.Parent = playerFolder
--loaddata
local savestuff = ds:GetAsync(player.UserId)
--print("data takes up ".. game:GetService("HttpService"):JSONEncode(savestuff):len().. "/260000")
local StatsFile = player.leaderstats
if savestuff then
for i,v in pairs(savestuff) do
if i % 2 == 0 then
StatsFile:FindFirstChild(savestuff[i - 1]).Value = v
end
end
end
end)
local function saveValues(player)
local saveData = {}
local StatsFile = player.leaderstats
for i,v in pairs(StatsFile:GetChildren()) do
saveData[#saveData + 1] = v.Name
saveData[#saveData + 1] = v.Value
end
ds:SetAsync(player.UserId, saveData)
end
game:BindToClose(function()
for i, player in pairs(game.Players:GetPlayers()) do
saveValues(player)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
saveValues(player)
end)
function oa(object)
local player = game.Players:playerFromCharacter(object)
if player ~= nil then
local ls = player.leaderstats
local sl = game.Workspace.Checkpoints:FindFirstChild(ls.Stage.Value)
print("gah")
wait(2)
object.Torso.CFrame = object.Torso.CFrame + Vector3.new(0,3,0)
object.Torso.CFrame = sl.CFrame + Vector3.new(0,3,0)
end
end
game.Workspace.ChildAdded:connect(oa)
If you look at the picture in the bottom right, it says to reset if you are not on your stage. The code is working as intended, as I assume you took this from a freemodel.
What are you trying to achieve here? Are you wanting the player to move to the last stage they were at when they join the game, are you trying to get the player to go the beginning when they reset their character?
Taking freemodels is fine, especially for learning scripting. There’s no shame in using them, though it’s good practice not to when you become better at scripting. So what exactly do you want to fix? Do you want to reset and stay at stage 1? Do you want to spawn at the stage you’re at?
The game has a date store for saving checkpoints, and I reached stage 19, re-entered and I appeared at the beginning, although stage 19 is written in the corner, and when I reset a character I appear at stage 19.