Hello, I really don't have much information on this issue other than the fact that sometimes when players load in, on their screen it saying they are on stage one, while on everyone else's screen it's the stage the player is actually on.
My script for saving stages
local datastore = game:GetService("DataStoreService"):GetDataStore("GameStore")
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("IntValue")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local level = Instance.new("IntValue")
level.Name = "Stage"
level.Parent = leaderstats
level.Value = 1
local key = "user-" .. player.userId
local storeditems = datastore:GetAsync(key)
if storeditems then
level.Value = storeditems[1]
else
local items = {level.Value}
datastore:SetAsync(key, items)
end
local spawn = game.Workspace:WaitForChild(player.leaderstats.Stage.Value)
if player and spawn then
player.Character:MoveTo(spawn.Position + Vector3.new(0, 3, 0))
end
end)
game.Players.PlayerRemoving:connect(function(player)
local items = {player.leaderstats.Stage.Value}
local key = "user-" .. player.userId
datastore:SetAsync(key, items)
end)
game.Workspace.ChildAdded:connect(function(obj)
local player = game.Players:GetPlayerFromCharacter(obj)
if player then
local leaderstats = player:FindFirstChild("leaderstats")
local stage = leaderstats:FindFirstChild("Stage")
local respawn = game.Workspace:WaitForChild(stage.Value)
obj.Torso.CFrame = obj.Torso.CFrame + Vector3.new(0,3,0)
wait(0.1)
obj.Torso.CFrame = respawn.CFrame + Vector3.new(0,3,0)
end
end)
