Hello, how do i make coins gui save? i’ve tried many ways to store it but doesn’t seem to work
so here is the script without save
local label = script.Parent
local coins = workspace.Coins
label.Text = “” … tostring(coins.Value)
coins:GetPropertyChangedSignal(“Value”):Connect(function()
print(“changed!”)
label.Text = " " … tostring(coins.Value)
end)
Your current script doesn’t include a datastore. You can easily save the value of the coins using DataStore | Roblox Creator Documentation. I think the easiest way to save it would be to have a dictionary template which is saved and updated when the player leaves/joins.
1 Like
I did this and doesn’t give me any error but still doesn’t work
local label = script.Parent
local coins = workspace.Coins
local HttpService = game:GetService(“HttpService”)
local DataStoreService = game:GetService(“DataStoreService”)
local DataStore = DataStoreService:GetDataStore(“GameStore”)
local Players = game:GetService(“Players”)
label.Text = “” … tostring(coins.Value)
Players.PlayerRemoving:connect(function(Player)
local Items = {
coins.Value,
}
Items = HttpService:JSONEncode(Items)
local Success, ErrorMessage = pcall(function()
DataStore:SetAsync(“user-”…tostring(Player.UserId), Items)
print(“changed!”)
label.Text = " " … tostring(coins.Value)
end)
if not Success then
warn("Failed to store data for user with id “…tostring(Player.UserId)…”. Error: "…ErrorMessage)
end
end)