How can I go about adding a server value to a datastore?

I want to do a weather changing based on days, but I’m unsure how to do the datastore so I can change the season based on the last day value any tips?

If it is server specific, instead of player ids, you can use server ids (it’s called JobId, sorry I don’t have api reference)

pretty much trying to count a day tick and if there’s a new server and a day, it will change for the next new servers

I’m confused to what you are trying to do. If you want to set the in game time to the user’s actual time, you can use os..

(I’m only wondering how should I start on the datastore since I’m inexperienced in datastores, I can manage to do for players but I dont know how to do server values)

1 Like

Use JobId (the game instance equivalent of userid)

1 Like

I know how to use os, but I want a server value to save for newer servers

do you have any useful forums that I can look into? or should I just search anything related to JobId

If days since publishing the game, I believe there is a way to get the game publish date and then just subtract it from the current date to get the amount of days (like in Robeats)

1 Like

Just search JobId, you’ll find what you need. I don’t have time to find the api reference sorry :frowning:

1 Like

I’m not sure what your goal is here, but you can do this to make a key that is used for only server-side stuff and not players:

local DataName = "YOURDATASTORENAMEHERE" -- Change
local KeyName = "YOURKEYNAMEHERE" -- Change
local Value = YOURVALUEYOUWANTTOSAVEHERE -- Change

local DSS = game:GetService("DataStoreService")
local DS = DSS:GetDataStore(DataName)

DS:SetAsync(KeyName,Value) -- Set the key

local Key = DS:GetAsync(KeyName,Value) -- Get the key

That should be all you need to do.

2 Likes

thanks a lot, it worked :pray: , managed to pull this off

No problem! Glad to help you! :wink:

Good luck!

1 Like