Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 comment

0

I want to make it so you have to equip a certain weapon for this script to run

2 answers

✓ Accepted answer

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.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.