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

?HELP? How i destroy a Gui from PlayerGui Folder when i will touch a part?

Asked by 4 years ago
Edited 4 years ago

Here is the script that put a Gui into PlayerGui Folder when i click a block:

function boop(Player) if not Player.PlayerGui:FindFirstChild("Gui") then local gui = script.Gui:clone() gui.Parent = Player.PlayerGui gui.LocalScript.Disabled = false end end script.Parent.ClickDetector.MouseClick:connect(boop)

The Gui that appears in PlayerGui Folder is named: Gui I need to make it destroy (the ”Gui” from PlayerGui Folder) when i touch a part named: Test2000

I hope u can help me guys!

0
so instead of clicking, you want it to be removed when touched? Subsz 366 — 4y

2 answers

Log in to vote
0
Answered by
Qu_xtty -8
4 years ago
Edited 4 years ago
local touchPart = -- The part you want to activate the gui:Destroy
local gui = -- The GUI

touchPart.Touched:Connect(function()
    gui:Destroy

Haven't tested, but it should work. If destroy doesn't work, here:

local touchPart = -- The part you want to activate the gui:Destroy
local gui = -- The GUI

touchPart.Touched:Connect(function()
    gui.Enabled = false

--IF ITS A FRAME THEN USE THIS--

touchPart.Touched:Connect(function()
    gui.Visible = false
Ad
Log in to vote
0
Answered by 4 years ago

--Put the script inside the Part local gui="Gui" -- the name of the gui local Players=game:GetService"Players" script.Parent.Touched:Connect(function(v) local char=v.Parent local player=char and Players:GetPlayerFromCharacter(char) local gui=player and player.PlayerGui:FindFirstChild[gui] gui=gui and gui:Destroy() end)

Answer this question