Ad
Log in to vote
0

Make an object move when clicked & dragged with CFrame?

Asked by
Sinieh -5
3 days ago
Edited 2 days ago

I have a script that makes a "wall decor" moved on only the x and y cords but the "wall decor" teleports on the roof when it collides with another part but not when it collides with another "wall decor." I think I might need to make it a CFrame. I can't figure out how though, I've tried many ways.

Add onto/fix this script: (make sure its a local script in starter pack.)

local player = game.Players.LocalPlayer local mouse = player:GetMouse() local mtarget local down

function clickObj() if mouse.Target ~= nil and mouse.Target.Name ~= "Baseplate" and mouse.Target.Name ~= "Part" then mtarget = mouse.Target print(mtarget) mouse.TargetFilter = mtarget print (mouse.TargetFilter) down = true 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,0)
    end
end mouse.Move:connect(mouseMove)

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

Much appreciated it, Thanks!

0
Try using CFrame to move Leamir 1139 — 3d
0
^ I was trying to avoid CFrame because I'm not at all good at it. Sinieh -5 — 3d
0
you can just use the position components of the cframe ex: CFrame.new(vector3pos) theking48989987 456 — 3d
0
Script doesn't work when I try that. Sinieh -5 — 3d

Answer this question