I’m making a simple warning system. However, I’m a bit lost on how I could save and load the warnings. So basically you type in someone’s name then click “Warn” and it creates a textbox with the players name. What I need to know how to do is to save that text box and load it back in when the players name is typed in and a “load button” is pressed. Anything helps.
How would I go about saving and loading GUI TextBoxs?
1 answer
What you want to do is to use the DataStoreService. It is a default service provided by Roblox which is useful for cases like your's.
I assume you want this spoon fed to you, although if I were in your position, so would I.
What you would want to do is use remote events to talk between your local scripts (child of each button), and server scripts (in ServerScriptService).
To learn more in-depth about data stores, follow this link to the roblox API: https://developer.roblox.com/en-us/articles/Data-store
Now then, you will want to paste the following into a local script as a child in your load button:
local datastoreservice = game:GetService("DataStoreService")
local mydatastore = datastoreservice:GetDataStore("-warnings")
local player = game.Players.LocalPlayer
local bttn = script.Parent
local savedWarnings
bttn.MouseButton1Click:Connect(function()
local success,err = pcall(function()
return mydatastore:GetAsync("-warnings"..player.UserId)
end)
if success then
savedWarnings = err
else
warn("An error occured: "..err)
end
end)
Depending on the format you use to save the information, you will likely need your own algorithm for placing the information neatly in the text box.
To save the warnings, you will also likely need your own algorithm. Paste the following into a local script:
local datastoreservice = game:GetService("DataStoreService")
local mydatastore = datastoreservice:GetDataStore("-warnings")
local player = game.Players.LocalPlayer
local bttn = script.Parent
local warnings = "GET THE WARNINGS FROM YOUR OWN STORAGE LOCATION"
bttn.MouseButton1Click:Connect(function()
-- FIRE A REMOTE EVENT TO THE SERVER
end)
When I say to get the warnings from your own storage location, that means I am assuming that you are storing the warnings in a variable or folder of some kind.
The last thing you will need is a server script. This will be used for actually storing the data for the warnings.
local datastoreservice = game:GetService("DataStoreService")
local mydatastore = datastoreservice:GetDataStore("-warnings")
[location].OnServerEvent:Connect(function()
local success,err = pcall(function()
mydatastore:SetAsync("-warnings"..player.UserId, warnings)
end)
if success then
local savedWarnings = err
else
warn("An error occured: "..err)
end
end)
You could use a remote function instead, however, I almost always use remote events.
To learn more about remote events and remote functions, follow this link to the roblox API: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events
Accept this answer if it solves your problem. If not, please feel free to clarify.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
If I understand correctly, you could just save the data(players name, ect) into a datastore and use a basic gui for everyone, then load the data back into the basic gui