I want to have a part when you touch it a GUI comes up and you are able to close it. In workspace I have a Part named "Part". In "Part" I have a script named "OpensExampleGui" in the script I have a GUI named "ExampleGui". In ExampleGui I have a frame named "ShopFrame". In ShopFrame I have a TextButton named "Close", I want "Close" to have a script that could close the whole Gui when touched! I also have other stuff in "ShopFrame" that is just text that does not need a script..
In "OpensExampleGui" (Script that opens the ScreenGui) This is the script:
wait(1) local near = false local debounce = true if near == true then while wait(0.1) do for i,v in pairs(game.Players:GetChildren()) do if v.Character.Torso ~= nil then if(v.Character.Torso.Position - script.Parent.Position).magnitude < (script.Parent.Size.X /1) + 10 then if v.PlayerGui:findFirstChild("ExampleGui") ~= nil then return end script.ExampleGui:clone().Parent = v.PlayerGui end end end end elseif near == false then if debounce == true then debounce = false script.Parent.Touched:connect(function(hit) local human = hit.Parent:findFirstChild("Humanoid") if (human == nil) then return end local player = game.Players:findFirstChild(hit.Parent.Name) if (player == nil) then return end if player.PlayerGui:findFirstChild("ExampleGui") ~= nil then return end script.ExampleGui:clone().Parent = player.PlayerGui end) debounce = true end end
This is the script that would close the whole Gui. Where do I put this??
function OnClicked() script.Parent.TextButton.BackgroundTransparency = 1 script.Parent.TextButton.TextTransparency = 1 script.Parent.BackgroundTransparency = 1 script.Parent.TextTransparency = 1 end script.Parent.MouseButton1Down:connect(OnClicked)
If yall don't understand, plz just help me make something where I could touch a part and a Gui comes up and it gives information and you are able to press a close button. I don't want a open button though! It would be great to link me to a youtube video also! Thanks so much, I would pay whoever help me out!
You're over-thinking it. Instead of making everything invisible, if you want to remove it from their PlayerGui, simple add ".Parent" until you reach the "ExampleGui", and Destroy it. Example:
script.Parent.MouseButton1Down:connect(function() script.Parent.Parent:Destroy() -- Keep adding '.Parent' until you reach the ExampleGui. end)
Or, if you think you'll get mixed up with the ".Parent"s, put this script. It'll work 100%!
-- Local Script inside the button script.Parent.MouseButton1Down:connect(function() p = game.Players.LocalPlayer p.PlayerGui.ExampleGui:Destroy() end)