Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Showing a gui while equiping a tool?

The title really sums it up, Im trying to make a GUI show up when you equipe a tool but its not working.

Tool = script.Parent
Gui= Tool:WaitForChild("StickGui"):clone()
 
Tool.Equipped:connect(function()
	print("Equipped")
	Gui.Parent = game.Players.LocalPlayerStarterGui
end)

Tool.Unequipped:connect(function()
	print("Unequipped")
	Gui:Destroy()
end)

(No errors its not even printing)

2 comments

0

Even though I already put my answer, try removing :WaitForChild("StickGui") to .StickGui as it might show an error. Whenever you wait for a child, it puts your whole script on hold, which means that no errors happen, until it finds the Child it is searching for.

0

It is a local script your thing dose not work it gives a error of "Unable to cast a value to Object" on line 3.

2 answers

Is it a server script or local script? If it’s a server script guis only work in local scripts.

Move to the Gui into StarterGui, make sure Enabled is off, and write the following into the tool script:

NOTE: I edited this script to fit a local script

local Tool = script.Parent
local plr = game.Players.LocalPlayer
local Gui = plr.StarterGui:WaitForChild("StickGui")

Tool.Equipped:connect(function()
    print("Equipped")
    Gui.Enabled = true
end)

Tool.Unequipped:connect(function()
    print("Unequipped")
    Gui.Enabled = false
end)

2 comments

0

It is a local script your thing dose not work it gives a error of "Unable to cast a value to Object" on line 3.

0

Fixed it. Maybe It will work now

This discussion is preserved as it was. New answers, comments, and votes are closed.