Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I change leaderboard stats to raise every 15 seconds from when the player joins?

I need help with changing this code so it raises 1 point every 15 seconds from when the player joins, not every 15 seconds the server is active and to make it so people in a certain group with a certain role will get a point raise, not guests:

amount = 1
timedelay = 15
currencyname = "Points"

while true do
	wait(timedelay)
	for i,v in pairs(game.Players:GetPlayers()) do
		if v:FindFirstChild("leaderstats") and v then
			v.leaderstats[currencyname].Value = v.leaderstats[currencyname].Value + amount
		end
	end
end

2 comments

0

What is the name of the leaderstat currency, is it points?

0

Points is the currency.

2 answers

✓ Accepted answer

LocalScript inside the PLAYER OBJECT

local remoteEvent = "PATH_TO_YOUR_REMOTE"


while true do
	wait(15)
	remoteEvent:Fire()
end

A script in ServerScriptService

local remoteEvent = "SAME_PATH_AS_LAST_ONE"


remoteEvent.OnServerEvent:Connect(function(player)
	player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1
end)

One issue with this is that it's veeeeeeeeeery exploitable. All an exploiter has to do is fire the remote to get +1 point, they could put this in a loop etc but you could check how often it's being fired from the client with tick() i think xd

This is just the leaderstat script, it might not work though, it is for a rough of what it can be like:

local Lplayer = game.Players.Localplayer -- Find Local player
local LplayerLeaderstat = game.Lplayer.Leaderstat -- Get local leaderstat

while true do -- Loop every 15 seconds
  wait(15)
   LplayerLeaderstat.Points.Value = LplayerLeaderstat.Points.Value + 1 -- +1 point
end

2 comments

0

It is much shorter and you can put a "if" loop around the "while true" loop to see if the LocalPlayer is in the group

0

Won't replicate to the server.

This discussion is preserved as it was. New answers, comments, and votes are closed.