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

How would I validate that this amount of time has passed?

So, I have a localscript that is added to the localplayer when they join and it waits 60 seconds then it fires a event and that event triggers a script to change the player's leaderstats... Edit: (this is looped by the way, it constantly waits 60 seconds then fires the event and then changes the player's leaderstats)

But the problem is that how do I check if 60 seconds have passed or not? Because if I can't check if 60 seconds have passed then exploiters can continuously fire my event and keep getting points... I want to stop them from being able to get a point if 60 seconds has not passed.

4 comments

0

I really need some assistance as I can't figure out how to do this

0

Please provide your code so we can assist you more accurately.

0

There done, the code I provided should work. Please click the correct button!

0

I will test your code outlook

2 answers

(Also next time. Please post your code.)

On the server side of things do something like this

game.Players.PlayerJoined:connect(function(plr)
	local seconds = 0
	
	while wait(1) do -- This will add seconds.
		if seconds == 60 then -- This will make it skip over the adding part.
			seconds = seconds + 1
		end
	end
	
	game.ReplicatedStorage.Event.OnServerEvent:connect(function(p,arugments)
		if plr == p and seconds == 60 then
			-- Add coins!!
			seconds = 0 -- This resets it back to 0 so you must wait another 60 seconds!
		end
	end)
end)

So every-time someone sends the event it checks if 60 seconds have passed. If you wanted this per player just put that code in game.Players.PlayerJoined:connect(function() and in the event check if the plr from the event is the plr that joined.

If this helped you please mark it as correct! Have a nice day! c:

3 comments

0

But the problem with this is it doesn't check if it's been 60 seconds for a specific user... Because when the localscript is added to a player that's when the 60 second wait starts... Not all players leaderstats are changed at once

0

yes, as I said if you wanted it for a specific user you would have to put it in a player joined function. I will edit it though.

0

You shouldn’t even give him the code. Look at how selfish and picky he is!

use server scripts since exploiters cant mess with them and there is no point of using local scripts for that

local seconds = 60 -- amount of seconds needed to wait before the coins are given
local added = 1 -- amount of coins added
game:GetService'Players'.PlayerAdded:connect(function(plr)
	while wait(seconds) do
		plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + added --adds the coins
	end
end)

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