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

Payday pays every sec whether then every 180 seconds how can I fix this?

Ok so the Payday script works (Thanks Goulstem for getting it to work) but it adds money every second whether then every whatever second it's at example 180 seconds. Also how can I show mins, hours and secs?

local time = 180

while wait(1) do
    time = time - 1
    if (time <= 0) then
        time = 180
    end
    for i,v in pairs(game.Players:GetPlayers()) do
        --different source directory
        local plr = game.ServerScriptService.Players:FindFirstChild(v.Name)
        if plr then
            --edit--
            local gui = v.PlayerGui:FindFirstChild('PaydayGui')
            --edit--
            local creds = plr.Tickets
            if gui then
                gui.Label.Text = 'Next payday in '..time..' seconds'
            end
            if v:IsInGroup(782018) then
                creds.Value = creds.Value + 50
            elseif v:IsInGroup(234706) then
                creds.Value = creds.Value + 30
            end
            creds.Value = creds.Value + 50
        end
    end
end

1 answer

✓ Accepted answer

To make it so it only awards you every x amount of seconds, you need to put the code inside your conditional on line 5. This way, it will count down and only award if the timer is at 0, then reset.


And sorry, i'm not going to answer about how to convert it to minutes / hours because that's not constructive on your part if I just do it for you.


local time = 180

--Make a function to award.

function awardPlayers()
	for i,v in pairs(game.Players:GetPlayers()) do
		local plr = game.ServerScriptService.Players:FindFirstChild(v.Name)
		if plr then
			local creds = plr.Tickets
			if v:IsInGroup(782018) then
				creds.Value = creds.Value + 50
			elseif v:IsInGroup(234706) then
				creds.Value = creds.Value + 30
			end
			creds.Value = creds.Value + 50
		end
	end
end

--Make a function to update the guis

function updateGuis()
	--Get all players
	for i,v in pairs(game.Players:GetPlayers()) do
		--Get gui
		local gui = v.PlayerGui:FindFirstChild('PaydayGui')
		--Make sure gui is there
		if gui then
			--Update it
			gui.Label.Text = 'Next payday in '..time..' seconds.'
		end
	end
end

while wait(1) do
	time = time - 1
	--Update the guis
	updateGuis()
	if time <= 0 then
		time = 180
		--Award the players INSIDE the conditional.
		awardPlayers()
	end
end

9 comments

0

That's fine and thx for fixing it again! :)

0

No problem.

0

Exactly now it's not working it's not showing any error what so ever o.O

0

What do you mean by conditional?

0

Nvm I understand now :P

0

Sorry, it's going to award you after 180 seconds but it's not going to show the countdown on players' leaderboards. It's because it's not updating the guis in the while loop. I'll edit it.

0

ah awesome thx so much!

0

Should work nao c:

0

It does thx so much!

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