i have a script to have a part follow the players mouse.
player = game.Players.LocalPlayer
mouse = player:GetMouse()
tool = game.StarterPack.Tool
local brick --define brick variable
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)
tool.Unequipped:connect(function() --fire when the tool is unequipped
if brick then
brick:Destroy() --if the brick exists then destroy it
end
end)
it is in the tool. if i put the script in starter scripts wiothout the onequip and uneuip parts, it works fine. but i want it to go away when i deselect the tool.
