i have a script to make a part follow the mouse when a tool is equipped
player = game.Players.LocalPlayer
mouse = player:GetMouse()
clicky = game.Workspace.placey
tool = script.Parent
local function onEquip()
brick = Instance.new("Part",workspace)
brick.BrickColor = BrickColor.new(1020)
brick.Size = Vector3.new( .01, 4, 4)
brick.Shape = "Cylinder"
brick.Anchored = true
mouse.TargetFilter = brick
mouse.Move:connect(function()
if mouse.Hit then
brick.CFrame = mouse.Hit
brick.Rotation = Vector3.new(0,0,-90)
end
end)
end
tool.Equipped:connect(onEquip)
if i take off the onEquip part, it works fine, but it never goes away. i want it to go away when i unequip the tool. any idea whats up with this?

3 comments
Place the part in the player's character model.
Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
sorry M39