Local script:
1 | local mouse = game.Players.LocalPlayer:GetMouse() |
2 | mouse.Button 2 Down:Connect( function () |
3 | script.Parent.Parent.PlayerGui.ScreenGui.ImageLabel.Visible = true --this makes it true so it then is visible |
4 | end ) |
5 | mouse.Button 2 Up:Connect( function () |
6 | script.Parent.Parent.PlayerGui.ScreenGui.ImageLabel.Visible = false |
7 | end ) |
if tool.Equipped then, or you could do tool.Equipped:Connect(function()
You could have just one script entirely in that certain weapon, something like this:
LocalScript btw.
01 | local weapon = script.Parent --this would be the tool, change it to where ever the tool is. |
02 | local equipped = false |
03 | local mouse = game.Players.LocalPlayer:GetMouse() |
04 |
05 | weapon.Equipped:Connect( function () |
06 | equipped = true |
07 | end ) |
08 |
09 | weapon.Unequipped:Connect( function () |
10 | equipped = false |
11 | end ) |
12 |
13 | mouse.Button 2 Down:Connect( function () |
14 | if equipped then |
15 | -- your GUI code here. |
Hope this helps.