I am trying to make a currency system which in this case are ‘SHILLINGS’, I made my data store script, as well as an increment of 10 shillings in 60 seconds using loops, but the script is not working.
The DataStore script inside ServerScriptService
local players = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")
local DataStore2 = require(1936396537)
local defaultShillingsAmount = 0
players.PlayerAdded:Connect(function(player)
local shillingsStore = DataStore2("shillings", player)
local function updateClientShillings(amount)
replicatedStorage.updateClientShillings:FireClient(player, amount)
end
updateClientShillings(shillingsStore:Get(defaultShillingsAmount))
shillingsStore:OnUpdate(updateClientShillings)
end)
while wait(60) do
for k, v in pairs(players:GetChildren()) do
local shillingsStore = DataStore2("shillings", v)
shillingsStore:Increment(10)
end
end
The Script in my Shillings Text Label,
local replicatedStorage = game:GetService("ReplicatedStorage")
replicatedStorage.updateClientShillings.OnClientEvent:Connect(function(amount)
script.Parent.Text = "SHILLINGS: " .. amount
end)