What do you want to achieve? Keep it simple and clear!
I’m making a global announcement script, and i want to it save when the server gets removed and added again
What is the issue? Include screenshots / videos if possible!
My script that i tried doesn’t works, i did something bad, but i can’t fix it
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I asked the guy who told me about datastores (and i saw threads) but i didn’t understand.
Script:
local DataStoreService = game:GetService("DataStoreService")
local msgstore = DataStoreService:GetDataStore("MessageStore") --Value that saves the message
local success, err = pcall(function()
msgstore:GetAsync(game.Workspace.GlobalAnnouncement.Value)
end)
local key = game.Workspace.GlobalAnnouncement.Value
if success then
print("Success!")
else
msgstore:SetAsync(key, "ohnub")
end
In short you are calling to get a key and then doing nothing with it.
local success, err = pcall(function()
msgstore:GetAsync(game.Workspace.GlobalAnnouncement.Value)
end)
This part right here, you request the API to get the value from a datastore at a key, but you do nothing with it. Also you seem to be calling the key as the last value you have which is more than likely going to be blank.
local success, key = pcall(function()
return msgstore:GetAsync(<the key in the datastore where the message is saved>)
end)
If these announcements are ephemeral (for example, they show up in livetime in the chat but don’t need to be called later) then the MessageService is a better option, otherwise take some time to read over the DevHub information on DataStores as linked by CodeJared.