I’ve tried making a point system that gives points to every players on the server in certain amount of seconds. However, it doesn’t give to every players and it only works for the first player on the server. If that player leaves, it’ll go to the second player on the server which I don’t know why. This is a server script in serverscriptservice.
local amount = 5
local defaultTime = 10
local timerText = defaultTime
local replicatedStorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local currencyTimerEvent = replicatedStorage:WaitForChild("CurrencyTimerEvent")
function updateText()
currencyTimerEvent:FireAllClients(amount,timerText)
end
while wait(1) do
timerText -= 1
updateText()
for _, player in ipairs(players:GetPlayers()) do
if player and player.Parent and timerText <= 0 then
timerText = defaultTime
player.leaderstats.Tots.Value += amount
end
end
end