So, in my game there’s this button that counts how many times its been clicked.
Problem is, I want it to save on any server so its global and also display the amount clicked every times its been clicked in any server.
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("Your Datastore name")
local myValue = game.ReplicatedStorage.MyValue
function load()
local data
data = DataStore:GetAsync("Your Key")
if data then
print(data)
myValue.Value = data
else
data = 0
end
update()
end
function update()
while wait(10) do
local data = DataStore:GetAsync("KEY")
myValue.Value = data
end
end
wait(5)
load()
Please note that this is just a sample code and it’s very basic.
please read DatastoreService:GetDataStore() documentation for more info.