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

"Freezing" the camera after being dragged by the mouse?

Asked by 9 years ago
wait()

mouse = game.Players.LocalPlayer:GetMouse()

cam = workspace.CurrentCamera
cam.CameraType = 'Scriptable'

mouse.Button1Down:connect(function()
    wait()
    mouse.Move:connect(function()
        cam.CoordinateFrame = CFrame.new(mouse.X/15,30, mouse.Y/15)*CFrame.fromEulerAnglesXYZ(-90,0,0)
    end)
end)

mouse.Button1Up:connect(function()
    wait()
    -- bit I can't figure out
end)

Hi, this has really stumped me.

I'm mostly a beginner so I don't know what's going wrong. The idea behind this is a top down camera that is moved based on the mouse's position when MB1 is down, and "frozen" in place after MB1 is lifted.

I have it working so it moves the camera when I press MB1 and move the mouse, but I can't figure out a way to freeze it.

I've tried: replicating a part and locking the camera's focus and coordinateframe to it replicating the position of the camera replicating the position of the mouse and probably a couple more things I can't think of

I'm sure this is something simple that I should have seen...

0
also just realized I made cam local which is completely unnecessary TheWindRises 0 — 9y
0
locals are fine ;-; LuaQuest 450 — 9y
0
yes but it wasn't needed TheWindRises 0 — 9y
0
you should ALWAYS use local variables whenever possible, even at the top of your script. They're slightly faster, even at the top, and a heck of a lot more readable. Perci1 4988 — 9y

Answer this question