Im trying to have an object follow the mouse when i press a guibutton button and have it stop following it when i press the same button how can you get it to stop following it
The following part works fine but it wont stop following
here is my code currently:
local Player = game.Players.LocalPlayer
local HandTracer = workspace.HAND_TRACER
local mouse = Player:GetMouse()
local squishbutton = game.StarterGui.Human_GUI.Squish_button -- the button pressed
if Player.Team.TeamColor == BrickColor.new("New Yeller") then
script.Parent.Parent.Enabled = true
script.Parent.MouseButton1Click:Connect(function()
if HandTracer.Transparency == 1 then
HandTracer.Transparency = 0.65
mouse.TargetFilter = game.Workspace.HAND_TRACER
while wait() do
game.Workspace.HAND_TRACER.CFrame = CFrame.new(mouse.Hit.p)
game.Workspace.HAND_TRACER.Orientation = Vector3.new(-90, 90, 0)
end
else
HandTracer.Transparency = 1
end
end)
end
if Player.Team.TeamColor == BrickColor.new("Black") then
script.Parent.Parent.Enabled = false
end

3 comments
line 13*
Couldnt get it too work
its not following the mouse anymore