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

How would I save/load my textbutton?

Asked by 7 years ago
Edited 7 years ago

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

Log in to vote
1
Answered by 7 years ago

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.

Ad

Answer this question