Title is pretty self explanatory. Tool.Equipped == true when the tool isnt equipped. Why is this happening?

Here is my code:

		
local Tool = script.Parent
local UserInputService = game:GetService("UserInputService")
local keyHeld = false

function holdTool(input,wasProcessed)
	keyHeld = true

		while UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) == true and keyHeld do
			local bodyPosition = game:GetService("Players").LocalPlayer.Character.HumanoidRootPart.Position
			local flyingBit =  Instance.new("Part",workspace.Flying_Pieces)
			flyingBit.Shape = Enum.PartType.Ball
			flyingBit.Anchored = true
			flyingBit.Transparency = 0.5
			flyingBit.BrickColor = BrickColor.new(23)
			flyingBit.Material = Enum.Material.SmoothPlastic
			flyingBit.Size = Vector3.new(7,1,7)
			flyingBit.CFrame = CFrame.new(bodyPosition.X,bodyPosition.Y-3.5,bodyPosition.Z)
			
			wait(0.1)
			for _, item in ipairs(workspace.Flying_Pieces:GetChildren()) do
		game:GetService("Debris"):AddItem(item, 1)
		end
	end

end
	


if Tool.Equipped then
	print("Enabled")
	UserInputService.InputBegan:Connect(holdTool)
else
	print("Disabled")
end

gif of issue: https://gyazo.com/003ffc590d2b6996905b7da29643a1eb

5 comments

0

You should probably use the tool:Activated() event instead, it is easier, unless it doesn't fit to your scripting plans. https://developer.roblox.com/en-us/api-reference/event/Tool/Activated

0

I'll move to using that in my script. Im still curious though about why Tool.Equipped was true when it definitely wasnt equipped.

0

Turns out using tool activated breaks functionality. It would be alot easier just to work out why tool.equipped is true. and making sure its the correct value

0

I am not sure, I have never used that kind of thing that is in your script. Usually if you use tool.Activated correctly it does the thing.

0

update: turns out tool activated does work. it was just getting broken by another piece of code.