I have absolutely no clue how to do this but I really need to know how to do it
use the .Equipped and Unequipped events of a tool. Then, make the gui visible
EXMAPLE
01 | Tool = game.StarterGear.Tool |
02 | Gui = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame |
03 |
04 | Tool.Equipped:connect( function () |
05 | Gui.Visible = true |
06 | end ) |
07 |
08 | -- Allows GUI to go away |
09 | Tool.Unequipped:connect( function () |
10 | Gui.Visible = false |
11 | end ) |
For more information, Use the rblox wiki and go to this link http://wiki.roblox.com/index.php?title=API:Class/Tool
And look at the events section
So I have just an example, I actually use this for my Mobile Controls Basketball.
01 | local plr = game.Players.LocalPlayer --This is a Local Script |
02 | local playerGui = plr:WaitForChild( "PlayerGui" ) --Better like this. |
03 | local controlGuiClass = script.Parent.ControlsGUI |
04 | local tool = script.Parent |
05 |
06 | --What I did was put the GUI inside the Tool. |
07 |
08 | tool.Equipped:connect( function () |
09 | local CGClone = controlGuiClass:Clone() |
10 | CGClone.Parent = playerGui --Transfer the Cloned GUI into the Player's GUI. |
11 | CGClone.TextButton.Visible = true --I have my Visibility turned off, so I manually turn it on in this script. |
12 | end ) |
13 |
14 | tool.Unequipped:Connect( function () |
15 | if playerGui:FindFirstChild( "ControlsGUI" ) then -- B/c it'll check the original variable, which you'll have to have the script |
16 | playerGui.ControlsGUI:Destroy() |
17 | end |
18 | end ) |
19 |
20 | --Whenever you Unequip that tool, the GUI would be destroyed, meaning if you didn't have the Unequipped function, you would have a GUI still on your screen lol. |
Also you could put it inside the Replicated Storage, but this method up here is more efficient, at least that's what I think.
Hopefully this helps, LukeGabrieI