I want to make something that when a play touches a part or clicks a button , their camera moves to an exact position, and they can't move it, and when they press a button their camera reverts to normal.
✓ ANSWER ACCEPTED
Camera movement question. How can i do it?
1 answer
✓ Accepted answer
wait() --Waits for player to load
function MoveCamera(cframe, button)
local prevCFrame = game:GetService("Workspace").Camera.CFrame
local camType = game:GetService("Workspace").Camera.CameraType
game:GetService("Workspace").Camera.CameraType = Enum.CameraType.Scriptable --Disables player moving camera
game:GetService("Workspace").Camera.CFrame = cframe --Set camera position
buttonEvent = button.MouseButton1Click:connect(function() --Change 'MouseButton1Click' to 'MouseClick' if using ClickDetector
game:GetService("Workspace").Camera.CameraType = camType
game:GetService("Workspace").Camera.CFrame = prevCFrame
pcall(function() --Incase of error
buttonEvent:Disconnect() --Disconnects event from function so it only runs once
end)
end)
end
--e.g. MoveCamera(CFrame.new(0, 10, 0), GuiButton)
edit:
local prevCFrame = game:GetService("Workspace").Camera.CFrame
local camType = game:GetService("Workspace").Camera.CameraType
Stores the players camera data.
game:GetService("Workspace").Camera.CameraType = Enum.CameraType.Scriptable
Removes the ability for the player to move the camera.
game:GetService("Workspace").Camera.CFrame = cframe
Sets the camera cframe to the one used in the function.
game:GetService("Workspace").Camera.CameraType = camType
game:GetService("Workspace").Camera.CFrame = prevCFrame
Sets the camera data back to before it was changed, fixes the camera.
buttonEvent:Disconnect()
Disconnects the event so it cannot run again.
Hopefully the edit helps.
1 comment
0
pls explain not in comments
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You're lucky you got help because requesting is not allowed, Ady