Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make this object mover hold object in the air?

Asked by
proo34 41
5 years ago
local plr = game.Players.LocalPlayer
repeat wait() until plr and plr.Character
local mouse = plr:GetMouse()
local mtarget
local down

mouse.Button1Down:connect(function()
 if mouse.Target ~= nil and mouse.Target.Locked == false and mouse.Target.Name == "CinderBlock" or mouse.Target.Name == "SodaCan" then
  print(mouse.Target.Name)
  mtarget = mouse.Target
  down = true
  mouse.TargetFilter = mtarget or mouse.Target
  end
end)



mouse.Move:Connect(function()
 if down == true and mtarget ~= nil then
  mtarget.Position = Vector3.new(mouse.Hit.X, mouse.Hit.Y, mouse.Hit.Z)
 end
end)


mouse.Button1Up:connect(function()
 down = false
 mouse.TargetFilter = nil
 mtarget = nil
end)

I have been working on this. It's been a headache to be honest. It has gotten to a working point where now I can move the objects but when I move them the move to the nearest surface and like you can pick it up.

Make a local script in StarterGUI if you don't understand.

Does anyone know how I could do this?

Answer this question