I’m having a huge major problem with my game where I have a gui where when you press a button it sends a webhook to my discord server. I’ve made a group rank only script inside the gui but it seems to not be working all the time. This is a problem as someone can spam ping everyone. Has anyone got anything that could help me make a group rank only script for a gui where only certain group ranks can see the gui. Here is my current script (It’s the script to make it so only certain people can see the open button for the button for the webhook):
local Player = game.Players.LocalPlayer
local OpenButton = script.Parent.OpenButton
local GroupId = 5062496 --Replace with your GroupId
local MinimumRank = 95 --Replace with Rank Value
if Player:GetRankInGroup(GroupId) < MinimumRank then
OpenButton:Destroy()
end
That script was in the gui and it was a local script.
It sounds like the current script you have is checking the player’s rank in the group and removing the “OpenButton” if their rank is below the specified minimum rank. However, it seems like you want to make it so only certain group ranks can see the entire GUI instead of just the “OpenButton”.
To achieve this, you can modify the script to check the player’s rank when the GUI is initially created and destroy the entire GUI if their rank is not within the specified range. Here’s an example script:
-- Replace with your group ID
local groupId = 5062496
-- Replace with the minimum and maximum group ranks allowed to see the GUI
local minRank = 90
local maxRank = 100
local player = game.Players.LocalPlayer
local playerRank = player:GetRankInGroup(groupId)
if playerRank < minRank or playerRank > maxRank then
script.Parent:Destroy()
end
This script should be placed within the GUI’s local script. It first collects the player’s rank in the group and compares it to the specified minimum and maximum ranks. If the player’s rank is not within the range, it destroys the entire GUI. This should prevent players outside of the specified rank range from seeing or interacting with the GUI.
Let me know if you have any further questions or if this solution works for you!
You’re very welcome! I understand your concern about exploiters, but unfortunately, there isn’t much that can be done to prevent them from accessing the GUI if they exploit their way into it.
One thing you can do is add additional security measures to your webhook functionality. For example, you could add rate limiting to ensure that a player can only send a webhook once every few minutes, or you could add verification steps to ensure that messages are only accepted if they come from a verified source. These measures won’t prevent exploiters from accessing the GUI, but they can help prevent them from abusing the webhook functionality.
Yes, your new script looks good and should function properly to destroy the OpenButton if the player’s rank is not within the specified range.
As for adding a cooldown to the OpenButton, a simple approach would be to use a debounce variable to track when the button has last been clicked and disable it if it was clicked less than 5 minutes ago. Here’s an updated version of your script that includes a cooldown:
-- Replace with your group ID
local groupId = 5062496
local OpenButton = script.Parent.OpenButton
-- Replace with the minimum and maximum group ranks allowed to see the GUI
local minRank = 95
local maxRank = 255
local player = game.Players.LocalPlayer
local playerRank = player:GetRankInGroup(groupId)
local debounce = false
function onClicked()
if debounce then
return
end
-- Add code to handle button click here
debounce = true
wait(300) -- 5 minute cooldown
debounce = false
end
OpenButton.MouseButton1Click:Connect(onClicked)
if playerRank < minRank or playerRank > maxRank then
OpenButton:Destroy()
end
This version of the script adds a onClick function that is called when the OpenButton is clicked. The function first checks if the debounce variable is true, which would indicate that the button was clicked less than 5 minutes ago. If this is the case, the function simply returns and does not run any of the button click code.
If the debounce variable is false, the button click code is executed, and debounce is set to true to indicate that the button has just been clicked. The script then waits for 5 minutes before setting debounce back to false, which will allow the button to be clicked again.
I hope this helps! Let me know if you have any further questions.
Thank you for letting me know but how would I made a cooldown on the text button inside the frame a cooldown when clicking it it prevents you from clicking it and it changes the text of the button to the countdown.
To implement a cooldown with a countdown on the text button inside the frame, you can modify the onClicked function to accomplish this. Here is an updated version of the onClicked function that includes a cooldown with a countdown:
local debounce = false
function onClicked()
if debounce then
return
end
local button = script.Parent.Frame.TextButton
button.Text = "5:00"
button.AutoButtonColor = false
local timeLeft = 300 -- 5 minutes in seconds
while timeLeft > 0 do
local seconds = math.floor(timeLeft % 60)
button.Text = string.format("%d:%02d", math.floor(timeLeft / 60), seconds)
wait(1)
timeLeft = timeLeft - 1
end
button.Text = "Open GUI"
button.AutoButtonColor = true
debounce = true
wait(5 * 60) -- 5 minute cooldown
debounce = false
end
This version of the onClicked function first sets the Text property of the button to “5:00” and disables the AutoButtonColor. It then initializes a timeLeft variable to 300, which represents the remaining time in seconds.
The function then enters a while loop that runs once per second as long as timeLeft is greater than 0. In each iteration of the loop, the function calculates the number of minutes and seconds remaining and updates the button text to reflect this.
After the countdown reaches 0, the function sets the button text back to “Open GUI” and re-enables AutoButtonColor. It then sets the debounce variable to true, waits for 5 minutes, and sets debounce back to false, which allows the button to be clicked again.
To use this function, simply replace the existing onClicked function with this new version in your script.
I hope this helps! Let me know if you have any further questions.
You would want to use a LocalScript for this, and you should put it inside the TextButton. Here are the steps you need to take:
Insert a Script into the TextButton (you can also right-click it and select “Insert LocalScript”).
Copy the updated version of onClicked function (that includes the cooldown) and paste it into the LocalScript.
Delete any existing MouseButton1Click connection for the TextButton (if there is one).
Add a new MouseButton1Click connection for the TextButton that calls the onClicked function when the button is clicked. You can do this by adding the following line of code after the onClicked function in the LocalScript: