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

Make an object move when clicked & dragged with CFrame?

Asked by 5 years ago
Edited 5 years 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 3138 — 5y
0
^ I was trying to avoid CFrame because I'm not at all good at it. User#22996 0 — 5y
0
you can just use the position components of the cframe ex: CFrame.new(vector3pos) theking48989987 2147 — 5y
0
Script doesn't work when I try that. User#22996 0 — 5y

Answer this question