Skip to content

Instantly share code, notes, and snippets.

@MrCrypticxDev
Last active June 9, 2021 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrCrypticxDev/7f465430a7efb7c4e3f13db322eaab9d to your computer and use it in GitHub Desktop.
Save MrCrypticxDev/7f465430a7efb7c4e3f13db322eaab9d to your computer and use it in GitHub Desktop.
a simple drag n' drop/click n' drag object script for roblox, local player **only**!
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local down
local mtarget
clickmoveon = true
function clickObj()
if mouse.Target ~= nil then
mtarget = mouse.Target
down = true
mouse.TargetFilter = mtarget
end
end
mouse.Button1Down:connect(clickObj)
function mouseMove()
if down and mtarget then
local posX,posY,posZ = mouse.hit.X, mouse.hit.Y, mouse.hit.Z
if clickmoveon then
mtarget.Position = Vector3.new(posX,posY,posZ)
end
end
end
mouse.Move:connect(mouseMove)
function mouseDown()
down = false
mouse.TargetFilter = nil
end
mouse.Button1Up:connect(mouseDown)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment