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

Is there a way I can put a cooldown on my GUI to prevent spam?

Asked by 3 years ago
Edited 3 years ago

SuggestionManager Script - (ServerScriptStorage)

local HttpService = game:GetService("HttpService")
local WebhookURL = "https:/wlSrdTP6FvqGPcwE7QZuidoaHoef3nV0iz_-HZkc6-H6U7b0En" --<<--WEBHOOK URL HERE

local function postToDiscord(Message)
    local Data = {
        ["content"] = Message
    }
    Data = HttpService:JSONEncode(Data)
    HttpService:PostAsync(WebhookURL, Data)
end

game.ReplicatedStorage.Suggest.OnServerEvent:Connect(function(Player, Suggestion)
    postToDiscord("Suggestion from " .. Player.Name .. ": " .. Suggestion)
end)

SuggestionScript - (StarterGui)

local Player = game.Players.LocalPlayer
local ToggleButton = script.Parent.ToggleButton
local SuggestionFrame = script.Parent.SuggestionFrame
local SuggestionBox = SuggestionFrame.SuggestionBox
local SubmitButton = SuggestionFrame.SubmitButton


ToggleButton.MouseButton1Click:Connect(function()
    if SuggestionFrame.Visible == true then
        SuggestionFrame.Visible = false
    else
        SuggestionFrame.Visible = true
    end
end)

SubmitButton.MouseButton1Click:Connect(function()
    local Suggestion = SuggestionBox.Text
    game.ReplicatedStorage.Suggest:FireServer(Suggestion)
end)

The Map for the GUI is

StarterGUI
|_
   SuggestionGUI
       |_
          SuggestionScript
          Suggestion Frame _
                                          |_
                                             SubmitButton
                                             SuggestionBox

0
Boy remove that webhook url from the script mixgingengerina10 223 — 3y
0
You can add debounce in the SubmitButton.MouseButton1Click part https://developer.roblox.com/en-us/articles/Debounce mixgingengerina10 223 — 3y
0
I'll take a look, and oops. Thanks. matthewwilson25 -17 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

You did not use a debounce.

A debounce is used for that occasion.

local Debounce = false
local Player = game.Players.LocalPlayer
local ToggleButton = script.Parent.ToggleButton
local SuggestionFrame = script.Parent.SuggestionFrame
local SuggestionBox = SuggestionFrame.SuggestionBox
local SubmitButton = SuggestionFrame.SubmitButton


ToggleButton.MouseButton1Click:Connect(function()
    if SuggestionFrame.Visible == true then
        SuggestionFrame.Visible = false
    else
        SuggestionFrame.Visible = true
    end
end)

SubmitButton.MouseButton1Click:Connect(function()
    if Debounce == false then
      Debounce = true
          local Suggestion = SuggestionBox.Text
          game.ReplicatedStorage.Suggest:FireServer(Suggestion)
      wait(5) -- how much time you want to debounce
          Debounce = false
    end
end)

I hope this helps.

0
Works great! Thank you! matthewwilson25 -17 — 3y
Ad

Answer this question