How do you make a double click button?

I’m trying to make a setting gui and I need help because my code is not working.

Code
local btn = script.Parent
local main = script.Parent.Parent.Parent.Main
local shadow = script.Parent.Parent.Parent.Frame_ShadowPng

btn.MouseButton1Click:Connect(function()
	main.KillPlayers.Visible = false
	main.ShopIcon.Visible = false
	main.Frame.Visible = false
	shadow.ShadowImage4.Visible = false
	shadow.ShadowImage8.Visible = false
	shadow.ShadowImage2.Visible = false
	shadow.ShadowImage3.Visible = false
end)

btn.MouseButton1Click:Connect(function()
	main.KillPlayers.Visible = true
	main.ShopIcon.Visible = true
	main.Frame.Visible = true
	shadow.ShadowImage4.Visible = true
	shadow.ShadowImage8.Visible = true
	shadow.ShadowImage2.Visible = true
	shadow.ShadowImage3.Visible = true
end)
Screenshots

image

Video Footage

Video - Drive

2 Likes

try something more like this:

local btn = script.Parent
local main = script.Parent.Parent.Parent.Main
local shadow = script.Parent.Parent.Parent.Frame_ShadowPng

btn.MouseButton1Click:Connect(function()
	main.KillPlayers.Visible = not main.KillPlayers.Visible
	main.ShopIcon.Visible = not main.ShopIcon.Visible 
	main.Frame.Visible = not main.Frame.Visible
	shadow.ShadowImage4.Visible = not shadow.ShadowImage4.Visible
	shadow.ShadowImage8.Visible = not shadow.ShadowImage8.Visible
	shadow.ShadowImage2.Visible = not shadow.ShadowImage2.Visible
	shadow.ShadowImage3.Visible = not shadow.ShadowImage3.Visible
end)
3 Likes

Thanks, once it works I’ll give you a solution.

3 Likes
 btn.Text =  "On" = not btn.Text = "Off"

Sorry to bother again, this is my code and once click it will say Off and click again On

1 Like

pretty rough, let me know if it works

local btn = script.Parent
local main = script.Parent.Parent.Parent.Main
local shadow = script.Parent.Parent.Parent.Frame_ShadowPng
local on = false

btn.MouseButton1Click:Connect(function()
    if on == false then
        btn.Text = "On"
    else
        btn.Text = "Off"
    end
    on = not on
	main.KillPlayers.Visible = not main.KillPlayers.Visible
	main.ShopIcon.Visible = not main.ShopIcon.Visible 
	main.Frame.Visible = not main.Frame.Visible
	shadow.ShadowImage4.Visible = not shadow.ShadowImage4.Visible
	shadow.ShadowImage8.Visible = not shadow.ShadowImage8.Visible
	shadow.ShadowImage2.Visible = not shadow.ShadowImage2.Visible
	shadow.ShadowImage3.Visible = not shadow.ShadowImage3.Visible
end)```
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.