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

How would I save/load my textbutton?

I've tried getting the arguments right in the methods :GetAsync() and :SetAsync() but nothing new happens like it doesn't save. I don't know if my arguments are wrong or what, no error occurs either. Any help?

-----Saving
	game.Players.PlayerRemoving:connect(function(plr)
local Data=game:GetService("DataStoreService")
local button=workspace.PartTwo:FindFirstChild("SurfaceGui").Frame:WaitForChild("Button")
-----Name
Data:GetDataStore("SaveApplication")
-----Save
	while wait(3) do
Data:SetAsync("Keysave",button)
	end
end)
------Loading
	game.Players.PlayerAdded:connect(function(plr)
local Data=game:GetService("DataStoreService")
local button=workspace.PartTwo:FindFirstChild("SurfaceGui").Frame:WaitForChild("Button")
-----Name
Data:GetDataStore("SaveApplication")
-----Save
Data:GetAsync("Keysave",button)
	end)

1 answer

✓ Accepted answer

You cannot save instances directly to ROBLOX DataStores. However, you can save the parameters of the TextButton.

For example, the position and text. An example of saving text, is

Data:SetAsync("Keysave", button.Text)

When a player joins another server, you can have the script create the TextButton and apply the DataStore's values.

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