How do I prevent people from spamming E?
local userInputService = game:GetService("UserInputService")
local Player = game:GetService("Players").LocalPlayer
script.Parent.Equipped:connect(function()
active = false
end)
userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent then return end
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.E then
if active then
active = true
script.Parent.RemoteEvent:FireServer()
wait(1)
active = false
else
script.Parent.RemoteEvent2:FireServer()
active = true
Player.PlayerGui:WaitForChild("GunGUI"):Destroy()
wait(1)
active = false
end
end
end
end)

3 comments
have you tried making the wait() longer?
Use a Server-sided Cooldown Hashmap on the OnServerEvent signal.
Struggage wait() is not a problem, because 1 second does take a while.