Some of my gui only works when you double click, or every 2nd click. I made a post about this but got to answers…
Here is a gutted version of my gui, use it in a blank world and paste them both into startergui and you’ll see what I mean. (keep in mind only some buttons will work since you dont have all the files lol)
removed gui files to avoid copying
I’ve been told that there is nothing wrong with my code by a fellow devfourm user, so I am not sure what the issue is?
All lobby buttons need to be double-clicked or the second button to be clicked for some reason, I just checked and it does the same for the menu screen buttons which share a similar code… I also have a hovering sound, when the mouse enters the button it makes a sound, but the sound on every button only plays when you’ve entered the button twice (so a lot of my stuff you have to do twice for it to work…) example: mouse enter button = no sound, mouse leave and re-enter button = sound. (just in case I didn’t explain the too well. lol)
BTW InPos and OutPos are frames where I use their positions to tween, which is easier for me. I added debounce in hopes of reducing spam opening buttons because the frames will not finish the tween if spammed and ruin the animation, but I realize now I could add a line where I wait for a tween to finish – so ignore that, I am new to scripting lol.
Donation (in the lobby, not menu) to open dono frame:
local Button = script.Parent
local player = game.Players.LocalPlayer
local InPos = player.PlayerGui.LobbyButtons.InPos.Position
local OutPos = player.PlayerGui.Menu.OutPos.Position
local ExitButton = script.Parent
local DonoFrame = player.PlayerGui.LobbyButtons.DonateFrame
local ButtonGui = player.PlayerGui.LobbyButtons
----------
local SettingsFrame = ButtonGui.SettingsFrame
local UpdatesFrame = player.PlayerGui.Menu.UpdatesFrame
----------
local debounce = false
script.Parent.MouseButton1Click:Connect(function()
if debounce == false then
debounce = true
ExitButton.MouseButton1Click:Connect(function()
DonoFrame.Visible = true
DonoFrame:TweenPosition(InPos)
if SettingsFrame.Visible == true then
SettingsFrame:TweenPosition(OutPos)
wait(0.5)
SettingsFrame.Visible = false
else
if UpdatesFrame.Visible == true then
UpdatesFrame:TweenPosition(OutPos)
wait(0.5)
UpdatesFrame.Visible = false
end
end
end)
task.wait(1)
debounce = false
end
end)
Fixed it! You were requesting it to be pressed twice. For example:
script.Parent.MouseButton1Click:Connect(function()
if debounce == false then
debounce = true
ExitButton.MouseButton1Click:Connect(function()
<stuff here>
end)
end
end)
That code was on each button. The following is the correct code:
local Button = script.Parent
local player = game.Players.LocalPlayer
local InPos = player.PlayerGui.LobbyButtons.InPos.Position
local OutPos = player.PlayerGui.Menu.OutPos.Position
local DonoFrame = player.PlayerGui.LobbyButtons.DonateFrame
local ExitButton = DonoFrame.ExitButton
local ButtonGui = player.PlayerGui.LobbyButtons
----------
local SettingsFrame = ButtonGui.SettingsFrame
local UpdatesFrame = player.PlayerGui.Menu.UpdatesFrame
----------
local debounce = false
script.Parent.MouseButton1Click:Connect(function()
if debounce == false then
debounce = true
DonoFrame.Visible = true
DonoFrame:TweenPosition(InPos)
if SettingsFrame.Visible == true then
SettingsFrame:TweenPosition(OutPos)
wait(0.5)
SettingsFrame.Visible = false
else
if UpdatesFrame.Visible == true then
UpdatesFrame:TweenPosition(OutPos)
wait(0.5)
UpdatesFrame.Visible = false
end
end
task.wait(1)
debounce = false
end
end)
Note: The fixed code is for the Dono Button ONLY. You will have to change the variables for each button.
No problem! Glad I could help. If you want to support me, Mark the message as solution and like it too if you want too! Hope your game goes well and good luck.