adeepJoin Date: 2010-02-06 Post Count: 274 |
For some reason it saves but sometime it doesn't... So I'm using auto save to save player stages on my obby and for some reason sometimes they will be load onto an older stage
code-
StageStore = game:GetService("DataStoreService"):GetDataStore("Stage") -- :GetDataStore("Stage") if you want to reset your players data change this to like Stage1 or Stage2 or something else
function oa(object)
wait(.1)
local player = game.Players:playerFromCharacter(object)
if player ~= nil then
local ls = player.leaderstats
local sl = game.Workspace:FindFirstChild(ls.Stage.Value)
object.Torso.CFrame = object.Torso.CFrame + Vector3.new(0,3,0)
wait()
object.Torso.CFrame = sl.CFrame + Vector3.new(0,3,0)
end
end
function oe(object)
if object.className == "Player" then
local ack = Instance.new("IntValue")
ack.Name = "leaderstats"
local ack2 = Instance.new("IntValue")
ack2.Name = "Stage"
ack2.Value = 1
ack2.Parent = ack
ack.Parent = object
local leaderstats = object:FindFirstChild("leaderstats")
local stage = leaderstats:FindFirstChild("Stage")
while true do
wait(20)
if object.userId > 0 then
StageStore:WaitForDataReady()
StageStore:SetAsync("Stage_"..object.userId, ack.Value)
end
end
game.Players.PlayerRemoving:connect(function(player)
StageStore:WaitForDataReady()
StageStore:SetAsync("Stage_"..object.userId, player.leaderstats.Stage.Value)
end)
end
end
game.Players.ChildAdded:connect(oe)
game.Workspace.ChildAdded:connect(oa) |
|
ash877Join Date: 2008-02-18 Post Count: 5142 |
need to use getasync in oe in order to get the stage value saved. |
|
adeepJoin Date: 2010-02-06 Post Count: 274 |
What's wrong now...? Doesn't save at all
Code -
StageStore = game:GetService("DataStoreService"):GetDataStore("Stage") -- :GetDataStore("Stage") if you want to reset your players data change this to like Stage1 or Stage2 or something else
function oa(object)
wait(.1)
local player = game.Players:playerFromCharacter(object)
if player ~= nil then
local ls = player.leaderstats
local sl = game.Workspace:FindFirstChild(ls.Stage.Value)
print("gah")
object.Torso.CFrame = object.Torso.CFrame + Vector3.new(0,3,0)
wait()
object.Torso.CFrame = sl.CFrame + Vector3.new(0,3,0)
end
end
function oe(object)
if object.className == "Player" then
local ack = Instance.new("IntValue")
ack.Name = "leaderstats"
local ack2 = Instance.new("IntValue")
ack2.Name = "Stage"
ack2.Value = 1
ack2.Parent = ack
ack.Parent = object
local leaderstats = object:FindFirstChild("leaderstats")
local stage = leaderstats:FindFirstChild("Stage")
ack2.Changed:connect(function(value)
if StageStore:GetAsync("Stage") then
StageStore:WaitForDataReady()
wait()
StageStore:SecAsync("Stage_"..ack.Parent.userId, value)
end
end)
end
end
game.Players.ChildAdded:connect(oe)
game.Workspace.ChildAdded:connect(oa) |
|
ash877Join Date: 2008-02-18 Post Count: 5142 |
your event for saving the stage during player-removing is not there. It can't save cuz' you deleted it? |
|
adeepJoin Date: 2010-02-06 Post Count: 274 |
I want it save when their stage is changed. What am I doing wrong? |
|
ash877Join Date: 2008-02-18 Post Count: 5142 |
StageStore = game:GetService("DataStoreService"):GetDataStore("Stage") -- :GetDataStore("Stage") if you want to reset your players data change this to like Stage1 or Stage2 or something else
function oe(object)
if object.className == "Player" then
local ack = Instance.new("IntValue")
ack.Name = "leaderstats"
local ack2 = Instance.new("IntValue")
ack2.Name = "Stage"
ack2.Parent = ack
ack2.Changed:connect(function() save(object,ack2.Value) end)
ack.Parent = object
local leaderstats = object:FindFirstChild("leaderstats")
local stage = leaderstats:FindFirstChild("Stage")
ack2.Changed:connect(function(value)
if StageStore:GetAsync("Stage") then
ack2=StageStore:GetAsync("stage",object.userId)
end
end)
end
end
function save(plr,stg)
StageStore:SetAsync(p.userId,stg)
end
function oa(object)
local player = game.Players:playerFromCharacter(object)
if player ~= nil then
local ls = player.leaderstats
local sl = game.Workspace:FindFirstChild(ls.Stage.Value)
wait()
object.Torso.CFrame = sl.CFrame + Vector3.new(0,3,0)
end
end
game.Players.ChildAdded:connect(oe)
game.Workspace.ChildAdded:connect(oa) |
|
ash877Join Date: 2008-02-18 Post Count: 5142 |
*Fixed version
StageStore = game:GetService("DataStoreService"):GetDataStore("Stage") -- :GetDataStore("Stage") if you want to reset your players data change this to like Stage1 or Stage2 or something else
function oe(object)
if object.className == "Player" then
local ack = Instance.new("IntValue")
ack.Name = "leaderstats"
local ack2 = Instance.new("IntValue")
ack2.Name = "Stage"
ack2.Parent = ack
ack2.Changed:connect(function() save(object,ack2.Value) end)
ack.Parent = object
local leaderstats = object:FindFirstChild("leaderstats")
local stage = leaderstats:FindFirstChild("Stage")
ack2.Changed:connect(function(value)
if StageStore:GetAsync("Stage",object.userId) then
ack2=StageStore:GetAsync("stage",object.userId)
end
end)
end
end
function save(plr,stg)
StageStore:SetAsync(p.userId,stg)
end
function oa(object)
local player = game.Players:playerFromCharacter(object)
if player ~= nil then
local ls = player.leaderstats
local sl = game.Workspace:FindFirstChild(ls.Stage.Value)
wait()
object.Torso.CFrame = sl.CFrame + Vector3.new(0,3,0)
end
end
game.Players.ChildAdded:connect(oe)
game.Workspace.ChildAdded:connect(oa) |
|
adeepJoin Date: 2010-02-06 Post Count: 274 |
You don't call the function tho? and i want it how i have it but just change what i need 2 i don't like connect to seperate functions :/
|
|
ash877Join Date: 2008-02-18 Post Count: 5142 |
StageStore = game:GetService("DataStoreService"):GetDataStore("Stage") -- :GetDataStore("Stage") if you want to reset your players data change this to like Stage1 or Stage2 or something else
function oe(object)
if object.className == "Player" then
local ack = Instance.new("IntValue")
ack.Name = "leaderstats"
local ack2 = Instance.new("IntValue")
ack2.Name = "Stage"
ack2.Parent = ack
ack2.Changed:connect(function() StageStore:SetAsync(p.userId,stg) end)
ack.Parent = object
local leaderstats = object:FindFirstChild("leaderstats")
local stage = leaderstats:FindFirstChild("Stage")
ack2.Changed:connect(function(value)
if StageStore:GetAsync("Stage",object.userId) then
ack2=StageStore:GetAsync("stage",object.userId)
end
end)
end
end
function oa(object)
local player = game.Players:playerFromCharacter(object)
if player ~= nil then
local ls = player.leaderstats
local sl = game.Workspace:FindFirstChild(ls.Stage.Value)
wait()
object.Torso.CFrame = sl.CFrame + Vector3.new(0,3,0)
end
end
game.Players.ChildAdded:connect(oe)
game.Workspace.ChildAdded:connect(oa) |
|
ash877Join Date: 2008-02-18 Post Count: 5142 |
*Whoops; made a mistake.
StageStore = game:GetService("DataStoreService"):GetDataStore("Stage") -- :GetDataStore("Stage") if you want to reset your players data change this to like Stage1 or Stage2 or something else
function oe(object)
if object.className == "Player" then
local ack = Instance.new("IntValue")
ack.Name = "leaderstats"
local ack2 = Instance.new("IntValue")
ack2.Name = "Stage"
ack2.Parent = ack
ack2.Changed:connect(function() StageStore:SetAsync(object.userId,ack2.Value) end)
ack.Parent = object
local leaderstats = object:FindFirstChild("leaderstats")
local stage = leaderstats:FindFirstChild("Stage")
ack2.Changed:connect(function(value)
if StageStore:GetAsync("Stage",object.userId) then
ack2=StageStore:GetAsync("stage",object.userId)
end
end)
end
end
function oa(object)
local player = game.Players:playerFromCharacter(object)
if player ~= nil then
local ls = player.leaderstats
local sl = game.Workspace:FindFirstChild(ls.Stage.Value)
wait()
object.Torso.CFrame = sl.CFrame + Vector3.new(0,3,0)
end
end
game.Players.ChildAdded:connect(oe)
game.Workspace.ChildAdded:connect(oa) |
|
adeepJoin Date: 2010-02-06 Post Count: 274 |
But your script does not SetAsync? it only gets? |
|
ash877Join Date: 2008-02-18 Post Count: 5142 |
trust me it works. |
|
adeepJoin Date: 2010-02-06 Post Count: 274 |
I did it... For some reason it sometimes doesn't spawn u on stage spawns u in air... Whats wrong? P.s i haven't tested the storing yet |
|
ash877Join Date: 2008-02-18 Post Count: 5142 |
probably cuz the stage is set to 0 before the game saves? Set the default stage to 1 or whatever the 1st stage is. |
|
adeepJoin Date: 2010-02-06 Post Count: 274 |
It's not saving/loading tho?
P.s I have a diff script that loads data it seems to work fine... |
|
adeepJoin Date: 2010-02-06 Post Count: 274 |
bump |
|