Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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
0
What is the name of the leaderstat currency, is it points? 6zk8 95 — 4y
0
Points is the currency. TrolliantBot 4 — 4y

2 answers

Log in to vote
0
Answered by
AspectW 431 Moderation Voter
4 years ago

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

Ad
Log in to vote
0
Answered by
6zk8 95
4 years ago
Edited 4 years ago

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
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 6zk8 95 — 4y
0
Won't replicate to the server. AspectW 431 — 4y

Answer this question