Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make the text buttons disappear when when the mouse button clicks?

Asked by 6 years ago

I am currently making a GUI for an upcoming game that I am making for Roblox. However, I am having difficulties making the Text, and Image buttons disappear when any of the Main Children are being clicked. The script was a load out GUI that I modified to fulfill my style of the game. So I can Understand That I may be difficult, and reside to other possibilities. Here is a sample of the script that I tried to modify: (more info at the bottom)

--{ Variables/Assignments }-- player = script.Parent.Parent.Parent backpack = player.Backpack

--{ Functions }-- function chooseClass(class) for i, v in pairs(backpack:GetChildren()) do v:remove() end for i, v in pairs(class:GetChildren()) do if v:IsA("Tool") then v:clone().Parent = backpack elseif v:IsA("HopperBin") then v:clone().Parent = backpack end

end



script.Parent.Main.Visible = false
script.Parent.Title.Visible = false
script.Parent.Assault.Visable = false
script.Parent.Medic.Visable = false
script.Parent.Recon.Visable = false
script.Parent.Support.Visable = false
script.Parent.Shop.Visable = false
script.Parent.Money.Visable = false

end

function onHumanoidDied(humanoid, player) script.Parent.Main.Visible = true script.Parent.Title.Visible = true script.Parent.Assault.Visable = true script.Parent.Medic.Visable = true script.Parent.Support.Visable = true script.Parent.Recon.Visable = true script.Parent.Shop.Visable = true script.Parent.Money.Visable = true end

for i, v in pairs(script.Parent.Main:GetChildren()) do v.MouseButton1Up:connect(function () chooseClass(v) end)

end

To put you In perspective there is a GUI labeled "StarterGUI" and Its Children Are The "Main". The main consists of 4 children being all text Buttons. "Support", "Recon", "Medic" and "Assault". Next there is an ImageButton Titled "Money". Next there are also 4 other buttons that contain many tween scripts (not important). The 5 buttons are also named "Shop", "Gadgets", "Assault", "Recon", "Support" and "Medic". Please respond soon!

                                                        -Shiftmaster27
0
RIP CODE greatneil80 2647 — 6y
0
dude use code blocks TheSkyofIndia 150 — 6y

2 answers

Log in to vote
0
Answered by
y3_th 176
6 years ago

All you have to do is make a .MouseButton1Click event connect to a function that deletes all text/image buttons. Although, it's preferred to delete the frame containing these buttons.

Examples:

--destroying one button

local Foo = script.Parent

Foo.MouseButton1Click:Connect(function() --script is child of foo the button
    Foo:Destroy()
end)
--destroying all text and image buttons 

local Foo = script.Parent
local FooFrame = Foo.Parent --assuming that Foo is child of FooFrame

--instead of a for loop going through all buttons, we just delete the frame for all buttons
Foo.MouseButton1Click:Connect(function()
    FooFrame:Destroy()
end)

--the gui will still pop up in PlayerGui after being destroyed
Ad
Log in to vote
0
Answered by 6 years ago
local GUI = --Whereever your GUI is located--

Detector = --Whereever your detector is but its easier for me to just type where it is in the bottom--
--Lets say the detector is in script.parent.parent.Delete.ClickDetector--

-- If you want to destroy the GUI (It cant be brought back unless cloned)--
function Delete()
    GUI:Destroy()
end
--On the bottom if you just a want it to not be visible but you can always make it visible again--

function Invisible()
    GUI.Visible = false
end


script.parent.parent.Delete.ClickDetector.MouseButton1Click:Connect(--Put Delete if you want it deleted or Invisible if you just dont want it Visible--)

If the game is Filtering enabled and you want to for some reason make it where everyone sees the GUI destroyed then you should use remoteevent/remotefunctions. Otherwise you should be good learning off this.

Answer this question