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

getting leaderstats on every login to the game

Asked by 10 years ago

I would like to know how to give player points every 24 hours, and so, even if the player is offline, the only thing needed would be to login to collect those points for the every day login bonus, but if u miss that day and login into the game the day after that, then u wont recieve the reward for the last day, am thinking put it to a function like: give player 100 points wait(24 hours) then if player hasnt collected the bonus yet, then dont restart the timer, keep it at that point, so that pkayer logs in and then timer moves again... if u know wat I mean... anyways, heres my script:

local stats = {"Points", "RW", "TDD"}

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model", player)
    leaderstats.Name = "leaderstats"
    for _, stat in pairs(stats) do
        local sv = Instance.new("IntValue", leaderstats)
        sv.Name = stat
    end
end)

while wait(3600) do
    for _,Player in pairs(game.Players:GetPlayers()) do
        if Player:FindFirstChild("leaderstats") then
            Player.leaderstats.Points.Value = Player.leaderstats.Points.Value +100
        end
    end
end

2 answers

Log in to vote
0
Answered by
Jackd44 35
10 years ago

This isn't really a proper response, so I apologise(I can't comment, so I have to post it as an answer). But I did see a thread and in the comments there, Articulating had said to use something called "os.time". Now, I'm not sure whether that will be of any help or not, but my guess is to use os.time and saving/loading last play time and compare it to the current play time.

But as I said, this isn't a proper response and it may not be of much help, but making it so you can give players points every 24 hours IS possible. Don't give up hope, someone with greater experience should hopefully give you better advice, but hopefully this will give you some sort of help. :)

0
thnx for trying bro :) LokHsuLi 10 — 10y
0
All good, just sorry that my help wasn't extremely useful! Jackd44 35 — 10y
Ad
Log in to vote
-2
Answered by 10 years ago

I do not believe there is a way to do this. At most you can have it so when the join the game they can get 5 points:

game.Players.PlayerAdded:connect(function (player)
if player:WaitForDataReady() then
local stats = Instance.new("Model", player)
stats.Name = "leaderstats"
local money = Instance.new("IntValue", stats)
money.Name = "Money"
player:LoadNumber("Money")
money.Value = money.Value + 5
end
end)

game.Players.PlayerRemoved:connect(function (player)
local stats = player:findFirstChild("leaderstats")
local money = stats:findFirstChild("Money")
player:SaveNumber("Money", money.Value)
end
0
oh... damn... but I saw a guy with some complicating script once and I think he got his answer... anyways... and this script looks like it can be abused, cos it doesnt say anything about time or day, but it just says +5 so people can log in and out all the time... LokHsuLi 10 — 10y
0
I can edit it to fix that, but remember that the timer will reset if the server is closed (everybody leaves) because there is nothing to keep the game time running. XanthicDragon 38 — 10y

Answer this question