Hello,i am making a game where the player has abilities and can use then when hitting a button on the keyboard and has a 'regen' time which takes 11 to 12 seconds and what can i do to prevent the player from firing the remote event again.

--Server script
function debounce(func)
    local isRunning = false   
    return function(...)       
        if not isRunning then
            isRunning = true
 
            func(...)          
 
            isRunning = false
        end
    end
end
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local shoot = ReplicatedStorage.ShootGaunletA
shoot.OnServerEvent:Connect(debounce(function(player, ability, cursor)
	if cursor ~= true then
		--kick player 
	end
	if ability ~= "PowerPunch" then
		--kick player 
	end
 	print(ability)
	

wait(11) --around somewhere here to prevent hackers 

	
end))

--local script
local ReplicatedStorage = game:GetService("ReplicatedStorage") 
function run()
 script.Parent.PowerPunch.Bar:TweenSize(UDim2.new(0,200, 0, 30), "Out", "Linear", 10,true, function()
	local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(Input,Processed)
  if not Processed then 
	if script.Parent.PowerPunch.Bar.Size == UDim2.new(0,200,0,30) then
    local MouseInput = Input.UserInputType 
    local KeyCode = Input.KeyCode 
     if KeyCode == Enum.KeyCode.V then
	    script.Parent.PowerPunch.Bar:TweenSize(UDim2.new(0,0, 0, 30), "Out", "Linear", 0.5,true)
		 wait(0.5)
           local ReplicatedStorage = game:GetService("ReplicatedStorage")
           ReplicatedStorage:WaitForChild("ShootGaunletA"):FireServer("PowerPunch",true)
		  run() -- any better way then doing this?
     end
    end
 end
end)
	
end)

end

run() -- any better way then doing this?

Thank you!

6 comments

0

Why are you connecting a new InputBegan event each time your function in ran?

0

Not too sure about that :P

0

What do i do then?

0

You will need something that both local can change and server can detect. Otherwise exploiters can fire event after searching it with RemoteSpy. Put something that you can see if firing event at that moment is unusual.

0

You can use a password system to make exploiting harder. But you can't escape from a professional exploiter as I know. Just look for unusual things to kick player.

0

all i need is an check if the player has fired it again before the time has ended. I do have multiple checks on the server side as i DONT trust the CLIENT at all for any sort of information