(please tell me if it’s the wrong category)
Hello,
I have a problem with my datastore2 script:
-
the output say “attempt to concatenate string with nil” but i don’t know how to fix this:
-
Output:
Explorer:
CurrencyServer script:
wait(game.Loaded)
local players = game:GetService("Players")
local replicatedstorage = game:GetService("ReplicatedStorage")
local Datastore2 = require(1936396537)
local defaultCurrencyAmount = 75
players.PlayerAdded:Connect(function(player)
local currencyStore = Datastore2("Money", player)
local function updateClientCurrency(amount)
replicatedstorage.RemoteEvents.UpdateClientCurrency:FireClient(player, amount)
end
updateClientCurrency(currencyStore:Get(defaultCurrencyAmount))
currencyStore:OnUpdate(updateClientCurrency())
end)
while wait(10) do
for k, v in pairs(players:GetChildren()) do
local currencyStore = Datastore2("Money", v)
currencyStore:Increment(1)
end
end
ClientCurrencyGUI script:
wait(game.Loaded)
local replicatedstorage = game:GetService("ReplicatedStorage")
replicatedstorage.RemoteEvents.UpdateClientCurrency.OnClientEvent:Connect(function(amount)
script.Parent.Text = amount
end)
If you want to see the module that i use (datastore2)
- So i want to know how to fix this because then the value doesn’t update…
the fail is this line: (line 6 in the output)
script.Parent.Text = amount
So, i don’t know why it fails because the server script fireClient a remote event of a value, the localScript register the value and change the text to the value.
(value is the “amount”)
Have a good day !