So basically, I need a GUI to pop up on the screen(its for ammo) when I equip my gun! I tried to put a ScreenGUI with frames and stuff inside the Handle of the gun... it does not show up when I grab the gun. I have looked at free models and the screengui is just inside the tool. I wish to make it like this... I tried to do a script where the screen gui is enabled when I equip the tool, it did not work. -- The big part is.. I need a GUI to pop up when I equip a tool, and the GUI must be able to be changed as values within the tool's local script is changed. Thank you!!!
So to have a function on a tool (your gun) being equipped you would have to use Tool:Equipped.
So in order to use this, first you need to set up a local way of getting to your gun and your player. Therefore I recommend putting the script in the GUI for the ammo.
1 | local gui = script.Parent |
2 | local player = script.Parent.Parent |
3 | local tool = player.Backpack:WaitForChild( "Gun" ) --Or if you have other ways of getting to the gun |
Now you have your'e local's you can access the gun and function when its equipped like this:
1 | local gui = script.Parent |
2 | local player = script.Parent.Parent |
3 | local Tool = player.Backpack:WaitForChild( "Gun" ) --Or if you have other ways of getting to the gun |
4 |
5 | Tool.Equipped:connect( function (mouse) |
6 | gui.Enabled = true |
7 | end ) |
And if you want to make it disappear when its unequipped you can make another function after the end using Tool:Unequipped. Using the wiki page here and the current script you could figure out what you need to do.
im not familar at all with tools but probably something like
1 | if gun.beingheld = true then -- not sure what the correct term is for beingheld |
2 | ammogui.Visible = true |
3 | if gun.beingheld = false then |
4 | ammogui.Visible = false |