Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Made a save script, but it doesn't work?

Asked by 8 years ago

I tried to make a save script but it doesn't work. Can you guys spot anything wrong with it?

game.Players.PlayerRemoving:connect(function(p)
if p:findFirstChild("Candies") then
p:SaveInstance("SavedStatPNum1339"..tostring(game.PlaceId),p.Candies)
end
end)
game.Players.PlayerAdded:connect(function(p)
for k = 1, 60, 0.03 do
wait()
if p:findFirstChild("Candies") and p.DataReady then break end
end
local Loaded = nil
if p:findFirstChild("Candies") and pcall(function() Loaded =  p:LoadInstance("SavedStatPNum1339"..tostring(game.PlaceId)) end) then
for j, v in pairs(Loaded:GetChildren()) do
pcall(function() p.Candies[v.Name].Value = v.Value end)
end
end
end)
0
You're using deprecated functions (save and load instance). Do not use data persitance, use datastores. GoldenPhysics 474 — 8y
0
:P But I want to save models ;-; TheChampOfKillers 45 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

By the way, if someone wants indentations, here ya go.

game.Players.PlayerRemoving:connect(function(p)
    if p:findFirstChild("Candies") then
        p:SaveInstance("SavedStatPNum1339"..tostring(game.PlaceId),p.Candies)
        end
        end)
        game.Players.PlayerAdded:connect(function(p)
            for k = 1, 60, 0.03 do
            wait()
            if p:findFirstChild("Candies") and p.DataReady then break end
            end
            local Loaded = nil
            if p:findFirstChild("Candies") and pcall(function() Loaded =  p:LoadInstance("SavedStatPNum1339"..tostring(game.PlaceId)) end) then
            for j, v in pairs(Loaded:GetChildren()) do
            pcall(function() p.Candies[v.Name].Value = v.Value end)
        end
    end
end)
0
(Scripting Helpers messed it up) TheChampOfKillers 45 — 8y
Ad

Answer this question