How to make an action confirmation Gui?

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)
1 Like

You can make the mayday button open the yes or no menu, then you can write the rest of your script on the yes or no buttons.

1 Like

I need proper scripts I can’t script well

1 Like

Sorry, we can’t give scripts. You can search around on YouTube or the DevForum.

1 Like

What’d you mean you can’t give scripts, everyone here I’ve asked so far has given me scripts

1 Like

To prevent abuse? An exploiter could just spam your remote as many times as they want… you must put a cooldown on the server side

there is a remote cooldown in this script you can copy:

1 Like

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)
1 Like

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.

1 Like

For the confirmGui, I have written game.PlayerGui.ConfirmGui but it is not working ingame

1 Like

This is not correct because the variable of the playerGui is this:

local PlayerGui = game:GetService("Players").LocalPlayer.PlayerGui

1 Like

It’s not working how do I define the ConfirmGui and the buttons? The ConfirmGui is called ConfirmGui and it is in StarterGui.

1 Like

A couple things to note:

  • 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)
1 Like

Explorer
It should look like this


And it should look like this when it will be enabled

Set the ScreenGui to Enabled = false

Cattura

Make a sript that when the Red button of the image gets triggered set the Enabled of the ConfirmGui to true

And this is the script of the ConfirmGui:

local confirmGui = script.Parent
local Frame = confirmGui:WaitForChild("MainFrame")
local yesButton = Frame:FindFirstChild("Yes")
local noButton = Frame:FindFirstChild("No")

yesButton.MouseButton1Click:Connect(function()
    game.ReplicatedStorage.SendWebhook:FireServer()
    confirmGui.Enabled = false
end)

noButton.MouseButton1Click:Connect(function()
    confrimGui.Enabled = false
end)
1 Like

I don’t understand why this isn’t working:

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()

confirmGui.Enabled = true

end)

yesButton.MouseButton1Click:Connect(function()

game.ReplicatedStorage.SendWebhook:FireServer()

confirmGui.Enabled = false

end)

noButton.MouseButton1Click:Connect(function()

confirmGui.Enabled = false

end)
1 Like

Are you getting any errors in your Output at all? I think I should mention the obvious: The Script needs to be a LocalScript for it to work

1 Like

It works now! I forgot to put the Frame in. :man_facepalming:

1 Like

Ah yes, Facepalming yourself for forgetting to do something

You’re fine though, at least you fixed it! (Oh yeah btw do make sure to mark your post as a solution so that members are aware of it :slightly_smiling_face:)

2 Likes

oh wait @JackscarIitt, how would I put a cooldown on it? to stop people submitting and again etc

1 Like

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)
1 Like

How long is the cooldown?

Just so I can write in the Gui that there is a cooldown

1 Like