Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a textbutton that switches the camera to a part? (read desc)

How to make a textbutton that switches the camera to a part and a cancel button that switches it back to the default camera? How???????????????????????????????????

1 answer

✓ Accepted answer

Alright, so let's begin. Start by inserting a part inside the workspace. Call it whatever you want. I will be calling it 'StartCamera'. Don't just call it 'Camera'. This will be the position of the camera.

Then go to screen Gui, and insert 2 text buttons. call both of the text buttons anything you want, I will call the first one 'ChangeCamera', and the second one, 'Go Back' insert a local script inside the ChangeCamera text button. Inside the local script, type this:

local CurrentCamera = workspace.CurrentCamera
local StartCamera = game.Workspace.StartCamera

script.Parent.MouseButton1Click:Connect(function()
	CurrentCamera.CameraType = Enum.CameraType.Scriptable
	CurrentCamera.CFrame = StartCamera.CFrame
	
	script.Parent.Parent.GoBack.Visible = true
end)

And inside the 'GoBack' text button, insert this local script:

local CurrentCamera = workspace.CurrentCamera
local StartCamera = game.Workspace.StartCamera

script.Parent.MouseButton1Click:Connect(function()
	CurrentCamera.CameraType = Enum.CameraType.Custom
	script.Parent.Visible = false
end)

This should be it. We are simply saying, that whenever we click on the change camera button, we change the CFrame of the currentcamera to the camera in the workspace. And when we click on the 'GoBack' textbutton, we change their camera to default camera.

Let me know if you need any help.

This discussion is preserved as it was. New answers, comments, and votes are closed.