Let's say I make a leaderboard and I want to add an increasing value every ten seconds (I'm using FE and RemoteEvents), how would I be able to do that. I tried adding the 'wait()' but I'd prefer another way.
For example, I have an argument like this: game.ReplicatedStorage.statFunc:FireServer(plr, value) game.ReplicatedStorage.statFunc:FireServer("100") but I want the value to increase every 10 seconds.
Script for creating the leaderstats and value:
local rStorage = game:GetService("ReplicatedStorage")
local Lead = rStorage:WaitForChild("leadFunc", rStorage)
local plr = game.Players.LocalPlayer
local function onLeadFired(plr, value)
local leader = Instance.new("IntValue")
local stats = Instance.new("IntValue")
leader.Name = "leaderstats"
leader.Parent = plr
wait(0.5)
stats.Name = "Stats"
stats.Value = value
stats.Parent = plr.leaderstats
end
Lead.OnServerEvent:connect(onLeadFired)
Script for changing stats:
local rStorage = game:GetService("ReplicatedStorage")
local Stat = rStorage:WaitForChild("statFunc", rStorage)
local plr = game.Players.LocalPlayer
local function onStatFired(plr, value)
local stats = plr.leaderstats.Stats
wait(0.5)
stats.Value = value
end
Stat.OnServerEvent:connect(onStatFired)
LocalScript for both:
local rStorage = game:GetService("ReplicatedStorage")
local Lead = rStorage:WaitForChild("leadFunc", rStorage)
local Stat = rStorage:WaitForChild("statFunc", rStorage)
local plr = game.Players.LocalPlayer
Lead:FireServer("100")
wait(10)
Stat:FireServer("200")
Forgive me. I do not know what a code block or inline code. Thanks!

1 comment
Thanks, I'll use the first one.