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

How do I make a gui appear when a tool is equipped ?

Asked by 7 years ago

I have absolutely no clue how to do this but I really need to know how to do it

2 answers

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

use the .Equipped and Unequipped events of a tool. Then, make the gui visible

EXMAPLE

Tool = game.StarterGear.Tool
Gui= game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame

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

-- Allows GUI to go away
Tool.Unequipped:connect(function()
Gui.Visible = false
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

0
would this be in a script or a local script ? sorry if im being nooby lol 1Messi3903 -5 — 7y
0
Local script, sorry for not elaborating on that User#17125 0 — 7y
0
im being very nooby sorry if im annoying but where do i put this local script ? 1Messi3903 -5 — 7y
0
anywhere, i recommend starter player scripts. Workspace also works. DO NOT put in storages or the serverscript service User#17125 0 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

So I have just an example, I actually use this for my Mobile Controls Basketball.

local plr = game.Players.LocalPlayer --This is a Local Script
local playerGui = plr:WaitForChild("PlayerGui") --Better like this.
local controlGuiClass = script.Parent.ControlsGUI
local tool=script.Parent

--What I did was put the GUI inside the Tool.

tool.Equipped:connect(function()
    local CGClone = controlGuiClass:Clone() 
    CGClone.Parent = playerGui --Transfer the Cloned GUI into the Player's GUI.
    CGClone.TextButton.Visible = true --I have my Visibility turned off, so I manually turn it on in this script.
end)

tool.Unequipped:Connect(function()
    if playerGui:FindFirstChild("ControlsGUI") then -- B/c it'll check the original variable, which you'll have to have the script
        playerGui.ControlsGUI:Destroy()
    end
end)

--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

0
Which parts would i change to make it fit my game. Would I have to change all the control things or what ? 1Messi3903 -5 — 7y
0
Basically lol. LukeGabrieI 73 — 7y
0
Luke, I know this is an old post, but I need your help! The equipped function part works, but not the unequipped function, I've tried everything I dont know that to do, help plz QueenNyree 0 — 5y
0
Queen, I know this is an old reply but you can try turning off required handle brodywth 97 — 4y

Answer this question