https://gyazo.com/25936ae2ba1c6fe39f9b8d8846768bd2
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("StageSaveSystem")
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder",player)
leader.Name = "leaderstats"
local Stage = Instance.new("IntValue",leader)
Stage.Name = "Stage"
Stage.Value = ds:GetAsync(player.UserId)
if Stage.Value == nil then Stage.Value = 0 end
player.CharacterAdded:Connect(function(character)
local spaw = workspace:FindFirstChild(tostring(Stage.Value))
spaw.Enabled = true
wait()
spaw.Enabled = false
end)
ds:SetAsync(player.UserId, Stage.Value)
Stage.Changed:connect(function()
ds:SetAsync(player.UserId, Stage.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
ds:SetAsync(player.UserId, player.leaderstats.Stage.Value)
end)
local stage = 10
function ot(hit)
if hit.Parent ~= nil then
local player = game.Players:playerFromCharacter(hit.Parent)
if player ~= nil then
if player.leaderstats.Stage.Value == stage - 1 then
local h = hit.Parent:FindFirstChild("Humanoid")
if h ~= nil then
if h.Health ~= 0 then
player.leaderstats.Stage.Value = stage
end
end
end
end
end
end
script.Parent.Touched:connect(ot)
