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

How would I make it so you have to have a certain weapon equipped to use this script?

Asked by 4 years ago
Edited 4 years ago

Local script:

local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Button2Down:Connect(function()       
    script.Parent.Parent.PlayerGui.ScreenGui.ImageLabel.Visible = true --this makes it true so it then is visible 
end)
mouse.Button2Up:Connect(function()
    script.Parent.Parent.PlayerGui.ScreenGui.ImageLabel.Visible = false
end)
0
I want to make it so you have to equip a certain weapon for this script to run Haker902c 18 — 4y

2 answers

Log in to vote
0
Answered by
Reec_0 15
4 years ago

if tool.Equipped then, or you could do tool.Equipped:Connect(function()

Ad
Log in to vote
0
Answered by 4 years ago

You could have just one script entirely in that certain weapon, something like this:

LocalScript btw.

local weapon = script.Parent --this would be the tool, change it to where ever the tool is.
local equipped = false
local mouse = game.Players.LocalPlayer:GetMouse()

weapon.Equipped:Connect(function()
    equipped = true
end)

weapon.Unequipped:Connect(function()
    equipped = false
end)

mouse.Button2Down:Connect(function()
    if equipped then
        -- your GUI code here.
    end
end)

mouse.Button2Up:Connect(function()
    -- GUI code to disable the GUI here.
end)

Hope this helps.

Answer this question