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

How do I make a tool that when equiped a gui pops up?

Asked by 6 years ago

I would like to know because I am working on a game needing this.

2 answers

Log in to vote
0
Answered by 6 years ago

Use the Equipped event of tools.

local tool = script.Parent
local plr = game:GetService("Players").LocalPlayer


tool.Equipped:Connect(function()
    plr.PlayerGui.ScreenGui.Frame.Visible = true -- assuming that's the Gui you have
end)
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Hello! We are going to be using the Equipped event found in Tools for this. This must be a LocalScript inside of a Tool.

If you are unaware of how tools work, you can study the wiki page at http://wiki.roblox.com/index.php/Tools . But just to make your life a little easier and answer your question, I'll show you how to do it.

First we'll just assign our variables:

local tool = script.Parent -- This is the variable to access the tool faster.
local gui = game.Players.LocalPlayer.PlayerGui.ScreenGui -- This is assuming you already have a ScreenGui in StarterGui. You can also change the name of the word ScreenGui at the end there to the name of the GUI that you have now.

For the next part, please make the Enabled property in your ScreenGui that you have in StarterGui set to false, where everything else inside of the Gui has their Visible set to true unless you need it otherwise.

tool.Equipped:connect(function()
    gui.Enabled = true
end)

If you do not already have a close button in your GUI, you will need to add this part:

tool.Unequipped:connect(function()
    gui.Enabled = false
end)

So now, without the comments I wrote for you, your end product should look something like this:

local tool = script.Parent
local gui = game.Players.LocalPlayer.PlayerGui.ScreenGui

tool.Equipped:connect(function()
    gui.Enabled = true
end)

tool.Unequipped:connect(function()
    gui.Enabled = false
end)

Please let me know if you have any questions, comments, or issues.

  • LordOfLuxury
0
This isn't working for me. I don't know why. Put at is into a tool with a handle in FE won't work? Local Script Clashing_McFTW -22 — 5y
0
Do you have the output open? Are there any errors? It could be that the script loaded before the PlayerGui. If so, then just simply add wait() a line above "local tool = script.Parent". LordOfLuxury 84 — 5y
0
I was having the same issue, for some reason running the localscripts inside the handle makes the local gui = etc give an error mantorok4866 201 — 5y

Answer this question