So I'm trying to make it so when I equip the tool, it will show up a gui. When you close it, it'll remove the gui. I don't know whats wrong so could anyone help? Thanks.
local tool = script.Parent -- Make sure that this script is in your tool
local gui = game.ServerStorage.Chat
local player = game.Players.LocalPlayer
tool.Equipped:connect(function(mouse)
local guiclone = gui:Clone()
guiclone.Parent = player.PlayerGui-- assuming you already have "player" defined
game.StarterGui:SetCoreGuiEnabled(3, true)
end)
tool.Unequipped:connect(function()
if player.PlayerGui:findFirstChild("Chat") then
player.PlayerGui:findFirstChild("Chat"):Destroy() -- removes "Gui"
game.StarterGui:SetCoreGuiEnabled(3, false)
end
end)

1 comment
try :FindFirstChild instead?