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 4 years ago
Edited 4 years ago

SuggestionManager Script - (ServerScriptStorage)

01local HttpService = game:GetService("HttpService")
02local WebhookURL = "https:/wlSrdTP6FvqGPcwE7QZuidoaHoef3nV0iz_-HZkc6-H6U7b0En" --<<--WEBHOOK URL HERE
03 
04local function postToDiscord(Message)
05    local Data = {
06        ["content"] = Message
07    }
08    Data = HttpService:JSONEncode(Data)
09    HttpService:PostAsync(WebhookURL, Data)
10end
11 
12game.ReplicatedStorage.Suggest.OnServerEvent:Connect(function(Player, Suggestion)
13    postToDiscord("Suggestion from " .. Player.Name .. ": " .. Suggestion)
14end)

SuggestionScript - (StarterGui)

01local Player = game.Players.LocalPlayer
02local ToggleButton = script.Parent.ToggleButton
03local SuggestionFrame = script.Parent.SuggestionFrame
04local SuggestionBox = SuggestionFrame.SuggestionBox
05local SubmitButton = SuggestionFrame.SubmitButton
06 
07 
08ToggleButton.MouseButton1Click:Connect(function()
09    if SuggestionFrame.Visible == true then
10        SuggestionFrame.Visible = false
11    else
12        SuggestionFrame.Visible = true
13    end
14end)
15 
16SubmitButton.MouseButton1Click:Connect(function()
17    local Suggestion = SuggestionBox.Text
18    game.ReplicatedStorage.Suggest:FireServer(Suggestion)
19end)

The Map for the GUI is

1StarterGUI
2|_
3   SuggestionGUI
4       |_
5          SuggestionScript
6          Suggestion Frame _
7                                          |_
8                                             SubmitButton
9                                             SuggestionBox
0
Boy remove that webhook url from the script mixgingengerina10 223 — 4y
0
You can add debounce in the SubmitButton.MouseButton1Click part https://developer.roblox.com/en-us/articles/Debounce mixgingengerina10 223 — 4y
0
I'll take a look, and oops. Thanks. matthewwilson25 -17 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

You did not use a debounce.

A debounce is used for that occasion.

01local Debounce = false
02local Player = game.Players.LocalPlayer
03local ToggleButton = script.Parent.ToggleButton
04local SuggestionFrame = script.Parent.SuggestionFrame
05local SuggestionBox = SuggestionFrame.SuggestionBox
06local SubmitButton = SuggestionFrame.SubmitButton
07 
08 
09ToggleButton.MouseButton1Click:Connect(function()
10    if SuggestionFrame.Visible == true then
11        SuggestionFrame.Visible = false
12    else
13        SuggestionFrame.Visible = true
14    end
15end)
View all 25 lines...

I hope this helps.

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

Answer this question