Tool Not Opening Gui

Why won’t this script work? The tool I’m equipping is supposed to open a UI but it’s not.

script.Parent.Equipped:Connect(function()
	local Gui = script.Gui:Clone()
	Gui.Parent = game.Players.LocalPlayer.PlayerGui
end)
script.Parent.Unequipped:Connect(function()
	game.Players.LocalPlayer.PlayerGui:WaitForChild("Map"):Destroy()
end)
1 Like
  1. Is your script a local script?
  2. Is Gui object accessible to the script?
  3. Any errors that you can provide?
1 Like
  1. Yes
  2. Yes, it’s inside the script
  3. No error
1 Like
local Gui = script.Gui
script.Parent.Equipped:Connect(function()
	Gui.Parent = game.Players.LocalPlayer.PlayerGui
end)
script.Parent.Unequipped:Connect(function()
	Gui.Parent=script
end)

How about like this example?

1 Like

Already tried something similar and it didn’t work.

1 Like

I think local not inside function were way better. Is this client or server and is gui it’s ScreenGui?

1 Like

The script is inside a tool inside the Player.Backpack. Yes it’s a screengui

1 Like

Is that LocalScript? Not Serverside Script right?

1 Like
local Gui

script.Parent.Equipped:Connect(function()
	if not Gui then
        Gui = script.Gui:Clone()
    end

    Gui.Parent = game.Players.LocalPlayer.PlayerGui
end)

script.Parent.Unequipped:Connect(function()
    if Gui then
        Gui:Destroy()
    end
end)
1 Like

How about turn off RequiresHandle at Tool? but if Equipped cant be fired

1 Like

see if the gui is enabled or its children is visible

2 Likes

Try this I added some debugging code lines

-- This script should be a LocalScript
local tool = script.Parent

tool.Equipped:Connect(function()
    print("Tool equipped")
    local Gui = script:FindFirstChild("Gui")
    if Gui then
        local clonedGui = Gui:Clone()
        clonedGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
        print("Gui cloned and parented to PlayerGui")
    else
        warn("Gui not found in the script")
    end
end)

tool.Unequipped:Connect(function()
    print("Tool unequipped")
    local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
    local mapGui = playerGui:FindFirstChild("Map")
    if mapGui then
        mapGui:Destroy()
        print("Map GUI destroyed")
    else
        warn("Map GUI not found in PlayerGui")
    end
end)

2 Likes

Nothing printed, the map is visible and it’s parent screengui is enabled, so idk what’s going on.

can you show picture tool with stuff? i see you say print doesnt show anything?
there only reason Tool equipped cant be trigger should be

First Make sure RequiresHandle it’s Disabled it in tool properties or you have add Part with name “Handle” in tool

Screenshot (558)

Disabling RequiresHandle worked, thanks!

I just have another issue with another tool, where it won’t clone into the player’s backpack from serverstorage. I have other tools that do the same and they work but for some reason one of them doesn’t do anything at all and won’t clone unless I manually drag it from serverstorage into the player through the explorer.

example i can say

game.ServerStorage['Tool Name']:Clone().Parent=player.Backpack

can ik where your script gonna put?

It’s in serverscriptservice and is run by an event.

BindableEvent?

workspace['Event'].Event:Connect(function(player,item)
	game.ServerStorage[item]:Clone().Parent=player.Backpack
end)

workspace.Part.Touched:Connect(function(hit) -- there was no debounce soo it willl be multiple problem
if hit.Parent and game.Players:FindFirstChild(hit.Parent.Name)then
workspace.Event:Fire(
	'Name Tool', -- item
	game.Players[hit.Parent.Name] -- player
)
end
end)

RemoveEvent (chars chars chasrs)