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

How do I make this script gives points during a specified time?

Asked by
4d0z 4
5 years ago

Hello!

I am currently working on a script that gives points starting from 6 AM to 8PM. Here's what I got so far:

amount = 2 --Amount of power we will give each time
timedelay = 5 --Amount of Seconds in between each time the power is rewarded 
currencyname = "Power" --Name 

minutesAfterMidnight = 0

while true do
    minutesAfterMidnight = minutesAfterMidnight + .5
    game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
    wait(0.1)

if game.Lighting.ClockTime == 6.000 then --checks for 6AM
    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
end
end

For some reason the time stops at 6 and gives me a few points. Am I looping something incorrectly?

0
Why are you running an infinite loop at line 13? pidgey 548 — 5y

Answer this question