Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

2 comments

0

You're using deprecated functions (save and load instance). Do not use data persitance, use datastores.

0

:P But I want to save models ;-;

1 answer

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)

1 comment

0

(Scripting Helpers messed it up)

This discussion is preserved as it was. New answers, comments, and votes are closed.