Im trying to make a script that makes it so that whenever the player holds down the mouse and has the mouse on a target, then the targets location will be moved, the issue is, the script isn’t working well, as while Im holding the mouse down, the part only moves once.
Script:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
if mouse.Move then
mouse.Target.Position = mouse.Hit.Position
end
end)
That wont do use mouse.Move:Connect(function) inside check if mouseHold is true. On the mouse.button1down mouseHold = true, for the mouse.button1up mouseHold = false.
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local mouseHold = false
mouse.Move:Connect(function()
if mouseHold then
mouse.Target.Position = mouse.Hit.Position
else
if not mouseHold then
-- Do nothing
end
end
end)
mouse.Button1Down:Connect(function()
mouseHold = true
end)
mouse.Button1Up:Connect(function()
mouseHold = false
end)