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

Data saving not working?

I'm trying to save a player's tycoon using Data Persistance and it doesn't seem to be working.

YES, I understand that Data Persistance is deprecated, but I don't think you can use DataStores to save Instances.

This is the script. It gives no errors. It is a script in ServerScriptService.

game.Players.PlayerRemoving:connect(function(player)
	if player:WaitForDataReady() then
		local TycoonName = player.PlayerTycoon.Value
		local PlayersTycoon = game.Workspace.Tycoons:FindFirstChild(TycoonName)
		
		player:SaveInstance("Tycoon", PlayersTycoon)
		print("saved")
	end
end)

game.Players.PlayerAdded:connect(function(player)
	if player:WaitForDataReady() then
		player:LoadInstance("Tycoon")
		print("loaded")
	end
end)

Any help is appreciated. Thank you!

1 answer

This is just a theory but I may have another answer for your problem.

TycoonName is PlayerTycoon.Value but sometimes making a variable a property of something doesnt work. Try doing TycoonName = player.PlayerTycoon and then when you do :FindFirstChild() replace TycoonName with tostring(TycoonName.Value). Also make sure that PlayersTycoon is a string value.

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