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

How would I check if a person is firing a remote too fast?

Asked by 4 years ago

my local script works fine

local Remote = game:GetService("ReplicatedStorage").RemoteEvent

local Tool = script.Parent
local Handle = Tool:WaitForChild('Handle')

local ReloadTime = Tool.ReloadTime -- A Intvalue with a value of 10
local CanShoot = true


Tool.Equipped:Connect(function(Mouse)

    Mouse.Button1Down:Connect(function()

        if CanShoot == true then

            Remote:FireServer()

            CanShoot = false

            wait(ReloadTime.Value)

            CanShoot = true

        end



    end)


end)

And then my ServerScript which I have a problem with

I'm confused on how to make a limit for it each second also shouldn't I use a dictionary because I want this to apply to each person not everyone?

For example if one shoots the other person has to wait

local Remote = game:GetService("ReplicatedStorage").RemoteEvent


local Num = 0

Remote.OnServerEvent:Connect(function(player)


end)

I dont understand or know what to do here lets say I wanted to do a sanity check and I didn't want them to fire more than once in 10 seconds

1 answer

Log in to vote
0
Answered by
3wdo 198
4 years ago
Edited 4 years ago

i think you need to do this:

local Remote = game:GetService("ReplicatedStorage").RemoteEvent

local Tool = script.Parent
local Handle = Tool:WaitForChild('Handle')

local ReloadTime = Tool.ReloadTime
local CanShoot = true
local debounce = true

Tool.Equipped:Connect(function(Mouse)

    Mouse.Button1Down:Connect(function()

        if CanShoot == true and debouce then
            debouce = false            
            Remote:FireServer()
        print("waits 10 seconds") -- try this and if this prints in the output 1 time then it works but if it says: waits 10 seconds(x2) or more then it dont work
            wait(10)
            debounce = true


            wait(ReloadTime.Value)


        end



    end)


end)

i made an edit cuz i forgot to turn it into roblox code

Ad

Answer this question