So I’m trying to make a money script everything works except one part, the error shows as line 22.
local players = game:GetService("Players")
local RS = game:GetService(“ReplicatedStorage”)
local DataStore2 = require(1936396537)
local defaultMoney = 0
players.PlayerAdded:Connect(function(player)
local currencyStore = DataStore2(“currency”, player)
local function UpdateMoney(amount)
RS.Events.UpdateMoney:FireClient(player, amount)
end
UpdateMoney(currencyStore:Get(defaultMoney))
currencyStore:OnUpdate(UpdateMoney)
end)
while wait(1) do
for k, v in pairs(players:GetChildren()) do
local currencyStore = DataStore2(“currency”, v)
currencyStore:Increment(3) --This is where error is being shown.
end
end
Can you tell us what is the error?
Crcoli737
(Crcoli737)
#3
I’m going to be honest. Just use the regular data store.
local dataStore = game:GetService(“DataStoreService”)
Instead of using DataStore2.
it says nil amount but im confused
Your Datastore isn’t linked to Datastore, try linking it up with DatastoreService. Also is currencyStore linked as a number value?
AlexiyOne
(AlexiyOne)
#6
Are you doing this in Roblox Studio?
Did you turn on use datastore in the settings?
What is the error?
theres a separte script for it
QufioixDev
(DeletedUser)
#8
I don’t really know much on datastrore2 but try reading this DataStore2 it might help.
Im more fimilar with datastore2
QufioixDev
(DeletedUser)
#10
What’s the error say in the output?