So, I used this stage script and it keeps spawning me at 0 stage even if im not 0 stage
What’s wrong with it? (I added wait() in local function OnCharacterAdded(char))
local DS = game:GetService("DataStoreService"):GetDataStore("Stage Save")
local function OnCharacterAdded(char)
wait()
game:GetService("RunService").Stepped:Wait()
local plr = game.Players:GetPlayerFromCharacter(char)
char:WaitForChild("HumanoidRootPart").CFrame = workspace.Checkpoints[tostring(plr.TeleportedStage.Value)].CFrame + Vector3.new(0,3.25,0)
end
function OnPlayerAdded(plr)
plr.CharacterAdded:Connect(OnCharacterAdded)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = plr
local stage = Instance.new("IntValue")
stage.Name = "Stage"
stage.Parent = stats
local TeleStage = Instance.new("IntValue")
TeleStage.Name = "TeleportedStage"
TeleStage.Parent = plr
TeleStage.Value = 0 or stage.Value
local key = "id_" .. plr.userId
local data = DS:GetAsync(key)
if data then
stage.Value = data
TeleStage.Value = stage.Value
else
DS:GetAsync(key, stage)
end
end
game.Players.PlayerAdded:Connect(OnPlayerAdded)
function OnPlayerRemoved(plr)
local key = "id_" .. plr.userId
local data = plr.leaderstats["Stage"].Value
DS:SetAsync(key, data)
end
game.Players.PlayerRemoving:Connect(OnPlayerRemoved)