How to Save a Single Value? (Not Player Data)

I am trying to save a single value that is inside a part (not player data) but I don’t know how to do it.
For more context, this value is displayed on a surface gui and gets 1 added to it every time a player touches a part. I just don’t know how to save a single value (once again it’s not player data, it’s just for the game). anyways if you know how to do this please help me, Thanks :slight_smile:

you can still use datastores and get the data, then change the value of it. Here is a script for it:

local part = game.Workspace.Part
local dss = game:GetService("DataStoreService")
local save = dss:GetDataStore("TouchedValue")

game:BindToClose(function()
save:SetAsync("Touched", part.TouchedValue.Value)
end)

local saveddata = save:GetAsync("Touched")
part.TouchedValue.Value = saveddata

Edit: I just realized there was a much better way to save, so I just changed it.

1 Like

You can add an integer into the SurfaceGUI, and get the script to call that when needed.
Image below is an example of what I am referring to.
image

1 Like

Thanks so much! I really needed to know this! :smiley: