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

How do i open a gui when a tool is equipped?

I'm trying to make a GUI open when a tool is equipped but i can't seem to do it.

This is my script so far.

gui = script.ScreenGui.Begin
Tool = script.Parent

Tool.Equipped:connect(function(mouse)
gui.Visible = true
end)

I've tried looking for scripts on google and moving the gui in multiple places to no avail.

I'm probably doing something that's really simple wrong, but i can't figure this out.

2 answers

✓ Accepted answer

You have to put the GUI in the Player's PlayerGui.

Guis only function in the PlayerGui. I'm going to use the Clone() function to make a copy of the GUI and move it to the player's GUI. You should also be using a Local Script.

Example,

-- Local Script in the tool in StarterPack
local plr = game.Players.LocalPlayer
local plrGui = plr:WaitForChild("PlayerGui")
local gui = script:WaitForChild("ScreenGui")
local Tool = script.Parent

Tool.Equipped:connect(function(mouse)
	local guiClone = gui:Clone()
	guiClone.Visible = true
	guiClone.Parent = plrGui
end)
On line 4, I removed the Frame because the whole thing has to be in a ScreenGui to work, and just moving the frame we would lose the ScreenGui. I also made all the variables Local, like you should do.

Good Luck

If I helped, don't forget to click the accept button. It helps a lot.

Maybe because for gui you put script.ScreenGuiwhen for tool you did script.Parent. Obviously this script is located inside a tool so try script.Parent.Parent.ScreenGui.Begin?

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