Hello comunity,
i am trying to make a plugin where you can upload song id’s wich other players will see when they open the plugin as well. for this i wanted to use data store and upload the players input to the data store using:
datastore:SetAsync()
when i test it, it all works but if i open the plugin again the data store has been resetted, im asuming this is because in the begin of the script im making a new data store. but i really dont know if its that or what it is and how to fix it please help.
This is my code:
local DataStoreService = game:GetService("DataStoreService")
local songs = DataStoreService:GetGlobalDataStore("Storage", "songs")
local function UploadSong(id)
print(globalsongs)
if #id > 0 then
if tonumber(id) then
uiText.Text = Info.checkingData
uiText.TextColor3 = Colors.blue
if globalsongs ~= nil then
for i,v in ipairs(globalsongs) do
if v == id then
uiText.Text = Info.alreadyThere
uiText.TextColor3 = Colors.red
return false
end
end
table.insert(globalsongs, #globalsongs+1, id)
else
globalsongs = {}
table.insert(globalsongs, 1, id)
end
local try, catch = pcall(function()
songs:SetAsync("All")
end)
if try then
uiText.Text = Info.hasBeenUploaded
uiText.TextColor3 = Colors.green
else
uiText.Text = Info.wentWrong
uiText.TextColor3 = Colors.red
wait(catch)
end
return true
else
uiText.Text = Info.onlyNumber
uiText.TextColor3 = Colors.red
return false
end
else
uiText.Text = Info.blankSpace
uiText.TextColor3 = Colors.red
return false
end
end