Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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
                             

3 comments

0

Boy remove that webhook url from the script

0

You can add debounce in the SubmitButton.MouseButton1Click part https://developer.roblox.com/en-us/articles/Debounce

0

I'll take a look, and oops. Thanks.

1 answer

✓ Accepted answer

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.

1 comment

0

Works great! Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.