Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would i DataStore a value that is not used by Players?

Asked by 5 years ago
Edited 5 years ago
local DataStoreService = game:GetService("DataStoreService"):GetDataStore("Supplies")

local Key = "WoodKey"



local WoodNeeded = Instance.new("IntValue")

WoodNeeded.Name = "WoodNeeded"

WoodNeeded.Parent = game.ServerStorage



local Save = DataStoreService:GetAsync(Key)



if Save then

WoodNeeded.Value = Save[1]

else

local Numbers = {WoodNeeded.Value}

DataStoreService:SetAsync(Key,Numbers)

end



while wait(10) do

print("Saving Wood")

local Key = "WoodKey"

local SaveGroup = {WoodNeeded.Value}

DataStoreService:SetAsync(SaveGroup, Key)

end

This is my code, i've set it to save the value every 10 seconds for testing purposes, but it still doesn't work.

I must be doing something wrong, but i still can't figure it out.

0
Just hardcode the datastore key as some constant string???????????? Amiaa16 3227 — 5y
0
I have shown the script, so any help would be appreciated. HeroKajusa 0 — 5y

Answer this question