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

is there a way to find out the last time a player fired a remote?

Asked by
Elixcore 1337 Moderation Voter
6 years ago
Edited 6 years ago

let's say the player's name is Donald Donald fired the Hello world remote event 5 minutes ago.

If Donald wants to fire Hello world again he needs to wait 10 minutes.

How do i find out the last time a certain player fired a certain remote?

2 answers

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

Well, as local players have their own scripts you can simply use a debounce

local Event = game:GetService('ReplicatedStorage'):WaitForChild('Hello world')
Debounce = true
local button = script.Parent --> doesn't need to be a button!
local t = 60 * 10 --> Your time to wait (I use * because I can simply change the '10' without needing to calculate every minute

button.MouseButton1Click:Connect(function()
    if Debounce then
        Debounce = false
        Event:FireServer()

        wait(t)

        Debounce = true
    end
end)

There are other ways too but I think this one is the easiest

0
You need to set debounce = false somewhere in your script but I dont see it. User#21908 42 — 6y
0
True, forgot that lol User#20388 0 — 6y
0
thank you, this isn't what i was looking for but it gave me an idea on how to make the script! Elixcore 1337 — 6y
0
Np xD User#20388 0 — 6y
Ad
Log in to vote
1
Answered by
hellmatic 1523 Moderation Voter
6 years ago
Edited 6 years ago

Calculate 10 minutes into seconds like this:

1 minute = 60 seconds

60 seconds * 10 = 600 seconds

So 10 minutes = 600 seconds

local CanFire = true -- to determine if the remote can be fired or not

function FireRemote()
    if CanFire then 
        CanFire = false -- set it to false
        Remote:FireServer()

        spawn(function() -- use spawn() so that the wait() does not stop the script from running
            wait(600) -- wait for 10 minutes
            CanFire = true -- set it to true so it can be fired again
        end)
    end
end
0
I already answered that lol User#20388 0 — 6y
0
Just took more long for me to answer because I put more explanation into it hellmatic 1523 — 6y
0
So much explanation for a debounce? lol, normally I do the same but I didn't think it would be needed for a debounce User#20388 0 — 6y
0
I explained it just in case he did not understand what it does hellmatic 1523 — 6y

Answer this question