I am currently writing a mayday script, on the current Gui, there is a Distress button, but this immediately sends the mayday. To prevent abuse, I want a Gui that says:
Are you sure you want to send a mayday?
Yes No
The Gui currently looks like this:
This is the current LocalScript for when it is clicked:
local button = script.Parent
button.MouseButton1Click:Connect(function()
game.ReplicatedStorage.SendWebhook:FireServer()
end)
Create a confirm gui and set it as Enabled = false
local button = script.Parent
local confirmGui = --Make the variable of the Gui
local yesButton = --Make the variable of the yes button
local noButton = --Make the variable of the no button
button.MouseButton1Click:Connect(function()
confirmGui.Enabled = true
end)
yesButton.MouseButton1Click:Connect(function()
game.ReplicatedStorage.SendWebhook:FireServer()
confirmGui.Enabled = false
end)
noButton.MouseButton1Click:Connect(function()
confrimGui.Enabled = false
end)
When the mayday button is clicked, make a GUI tweened/visible with two buttons “yes” and “no”. Detect when the yes button is pressed, and fire a remote event to the server (preferably with a debounce). If the player presses no, just make the GUI tween away/invisible.
StarterGui’s UI Objects will be replicated to the Player whenever they join & created in a new local GUI called: The PlayerGui
game.Players.LocalPlayer is what you want when defining the local player/client
PlayerGui is a parent of the Player object, so you can easily get that
If ConfirmGui is just a regular ScreenGui, you can just use the Enable properties
Cancel & Confirm need to be both TextButtons
Code Reference:
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local Button = script.Parent
local ConfirmGui = PlayerGui:WaitForChild("ConfirmAction")
local Confirm = ConfirmButton.Confirm
local Cancel = ConfirmButton.Cancel
Button.MouseButton1Click:Connect(function()
ConfirmGui.Enabled = true
end)
Confirm.MouseButton1Click:Connect(function()
--Do your stuff here
ConfirmGui.Enabled = false
end)
Cancel.MouseButton1Click:Connect(function()
ConfirmGui.Enabled = false
end)
Just simply implement a debounce (Which is basically a cooldown)
local ActivateOnce = false
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local button = script.Parent
local confirmGui = PlayerGui:WaitForChild("ConfirmAction")
local yesButton = confirmGui.Yes
local noButton = confirmGui.No
button.MouseButton1Click:Connect(function()
if ActivateOnce == false then --This will just check if you've activated the tool, if you have then it'll only be activated once and you can't use it anymore
ActivateOnce = true
confirmGui.Enabled = true
end
end)
yesButton.MouseButton1Click:Connect(function()
game.ReplicatedStorage.SendWebhook:FireServer()
confirmGui.Enabled = false
end)
noButton.MouseButton1Click:Connect(function()
confirmGui.Enabled = false
end)