You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
User can submit a note to be saved.
Note can be accesed in another game/server (aka datastore) -
What is the issue? Include screenshots / videos if possible!
Local script inside gui
local temp = script.Template
local function Load()
local data = game.ReplicatedStorage.Folder["Data Get"]:InvokeServer()
if data == "False" then
print("No saved notes")
script.Parent.TextLabel.Text = "LOAD SAVES // no saved notes"
else
print(game:GetService("HttpService"):JSONDecode(data))
print(data)
print(#game:GetService("HttpService"):JSONDecode(data))
print(#data)
end
end
wait(1)
Load()
Output >
15:34:30.408 table: 0x5a03fa272975691f - Client - LocalScript:9
15:34:30.408 {"2":{"Name":"2","Text":"secomd note test text","Desc":"seecondd note"}} - Client - LocalScript:10
15:34:30.408 0 - Client - LocalScript:11
15:34:30.409 296 - Client - LocalScript:12
How could I get the amount of notes, and get the necesary info for my teemplate (image below)
Script for storing notes
Script for storing notes:
local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetDataStore("Notes")
local function saveNote(Player, Name, Desc, Value)
print(Player, Name, Desc, Value)
local note = {
[Name] = {
Name = Name,
Desc = Desc,
Text = Value
}
}
dataStore:SetAsync(Player.UserId, game:GetService("HttpService"):JSONEncode(note))
end
game.ReplicatedStorage.Folder["Data Store"].OnServerEvent:Connect(saveNote)
Script for getting notes
script for getting notes:
local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetDataStore("Notes")
local function saveNote(p)
local data = dataStore:GetAsync(p.UserId)
if data ~= nil then
return data
else
return "False"
end
end
game.ReplicatedStorage.Folder["Data Get"].OnServerInvoke = saveNote
One more issue with storing notes, it doesnt add another note but just replaces the current one.
