I’m trying to make an ammo counter for this Warbound gun, but when I place it in the class selecting GUI, the ammo box shows up on the screen. I want to make the GUI for the gun to only show up when the tool is pulled out, not just on the screen.
ok here are some hints:
- Disable the visible property of that gui (put it to false)
- There exists a function named :Equipped() which fires when the tool is equiped
- inside of Equiped function put visible property of gui to true
- There exists another function called :Unequipped(
- Inside of Unequipped function put visible property of gui to false
good luck
If you look through the ScreenGui properties you will find Enabled set to true, set it to false. And you can set it back to true through a script whenever you want it enabled. (Make sure you enable it from the player’s PlayerGui)
Also follow @nuttela_for1me hints, pretty cool.
where would I find :Equipped()
.Equipped and .Unequipped are built in events to tools. It fires whenever the tool is equipped and can be connected to a function like this:
tool.Equipped:Connect(function()
-- Do things
end)
tool.Unequipped:Connect(function()
-- Do things
end)
would this still work for tools without handles needed?
You can turn off the need for handles if you set your tools “RequiresHandle” property to false and the events will still fire.
There are multiple ways of doing this. Here are some:
- Setting the Enabled property of the ScreenGUI to false.
- Cloning the ScreenGUI from another place into the PlayerGui
- If everything is generated in a single frame, you can just set the visibility of said frame to false.
The way you can detect when the weapon is loaded is similar to how you can check when the tool is used. tool:Equipped() for when it gets equipped and tool:Unequipped() for when it gets unequipped, although I am judging that you already knew this if you were to script your own weapon.
I’m using a warbound kit. (30 characters)