Advertisement
Guest User

Click-to-Move a block! Roblox

a guest
Mar 30th, 2020
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.67 KB | None | 0 0
  1. player=game.Players.LocalPlayer
  2. mouse=player:GetMouse()
  3. mtarget
  4. down
  5.  
  6. function clickObj()
  7.     if mouse.Target == nil and mouse.Target.Name == {"WallX1","WallX2","WallZ1","WallZ2","Roof","Floor","Baseplate"} then
  8.         mtarget = mouse.Target
  9.         print(mtarget)
  10.         mouse.TargetFilter = mtarget
  11.         print(mouse.TargetFiletr)
  12.         down = true
  13.     end
  14. end
  15. mouse.MouseButton1Down:Connect(clickObj)
  16.  
  17. function mouseMove()
  18.     if down and mtarget then
  19.         local posX,posY,posZ = mouse.Hit.X,mouse.Hit.Y,mouse.Hit.Z
  20.         mtarget.Position = Vector3.new(posX,posY,posZ)
  21.     end
  22. end
  23. mouse.MouseMove:Connect(mouseMove)
  24.  
  25. function mouseDown()
  26.     down = false
  27.     mtarget = nil
  28.     mouse.TargetFilter = nil
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement