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)
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)