Hello Developers,
I am a builder not a programmer therefore I do not have much expertise in this topic, but I require some help because I was trying to create an economy script and I am left without script errors; I have only one of the 2 data stores saving the values within the player. This may be easy to fix I’m not entirely sure, and to note I do have API access enabled and as I said one data store is currently working.
Here is the script, if someone could figure this out for me that would be amazing.
local DATA_STORE_SERVICE = game:GetService("DataStoreService")
local MONEY_STORE = DATA_STORE_SERVICE:GetDataStore("EconomyMoney")
local JOIN_STORE = DATA_STORE_SERVICE:GetDataStore("JoindBefore")
local GAME_PLAYERS = game.Players
GAME_PLAYERS.PlayerAdded:Connect(function(PLAYER)
local MONEY_STAT = Instance.new("NumberValue")
MONEY_STAT.Name = "MONEY_AMOUNT"
MONEY_STAT.Parent = PLAYER
local JOINED_STATUS = Instance.new("BoolValue")
JOINED_STATUS.Name = "JOINED_BEFORE"
JOINED_STATUS.Parent = PLAYER
local DATA = MONEY_STORE:GetAsync(PLAYER.UserId)
if JOINED_STATUS.Value == false then
MONEY_STAT.Value = MONEY_STAT.Value + 50
JOINED_STATUS.Value = true
JOIN_STORE:SetAsync(PLAYER.UserId, JOINED_STATUS.Value)
end
while wait(5) do
MONEY_STAT.Value = MONEY_STAT.Value + 50
end
MONEY_STAT.Changed:Connect(function(NEW_VALUE)
MONEY_STORE:SetAsync(PLAYER.UserId, MONEY_STAT.Value)
end)
end)
GAME_PLAYERS.PlayerRemoving:Connect(function(PLAYER)
local MONEY_STAT = PLAYER.MONEY_AMOUNT
MONEY_STORE:SetAsync(PLAYER.UserId, MONEY_STAT.Value)
end)
The JOIN_STORE
datastore is working and saves a bool value for when the player has joined before but the other datastore is currently not working.