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

Can seem to limit dragging a item only to one item and move anywhere in view?

Asked by 5 years ago

We are trying to move a group of items and make them dragable. for instance a body which we can move but make the tomb solid which has to be blasted/pick axed away.

At the moment i've got this in my script but i'm not sure how to make the "Body" only the moveable bit it only works on the baseplate and takes each part but we want the whole body to move not individual parts.

local player = game.Players.LocalPlayer

local mouse = player:GetMouse()

local down

local mtarget

function clickObj()

if mouse.Target ~= nil then

mtarget = mouse.Target

print(mtarget)

down = true

mouse.TargetFilter = mtarget

print(mouse.TargetFilter)

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

mtarget.Position = Vector3.new(posX,posY,posZ)

end

end

mouse.Move:connect(mouseMove)

function mouseDown()

down = false

mouse.TargetFilter = nil

end

mouse.Button1Up:connect(mouseDown)

any help would be fantastic.

Thank you this is located in our "StarterPack" I was just following tutorials on the internet on how to script as my coding knowledge is very low.

Answer this question