I have a simple gun that destroys a certain part when clicked on said part. Here's the very basic script, without the code to destroy the part:
local enabled = true
function Down(mouse)
-- code to perform the task of destroying certain parts goes here
end
function Selected(mouse)
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = "http://www.roblox.com/asset/?id=212765652"
local l = game.Players.LocalPlayer.PlayerGui.bow.Frame:findFirstChild("slideValue")
mouse.Button1Down:connect(function() Down(mouse) end)
end
script.Parent.Equipped:connect(Selected)
function unSelected(mouse)
local l = game.Players.LocalPlayer.PlayerGui.bow.Frame:findFirstChild("slideValue")
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Icon = ""
end
script.Parent.Unequipped:connect(unSelected)
The problem is that even when the tool is unequipped, it still fires. When there isn't code to change the mouse's icon, the tool doesn't do this, so that is the main problem here. Why is it doing this?
EDIT: A very easy way to solve this would to check if the tool is equipped and THEN play the script. Unfortunately, I don't know how I would check if the tool is equipped in an "if then" statement. So, I'll need help with that.
