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

Im Tryna Do A Camera GUI but idk how to make the camera go back to normal?

So I'm doing a camera GUI idk how to set the camera back to normal with a button.




local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera


script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent:WaitForChild("Frame").Visible = true
repeat wait()
	Camera.CameraType = Enum.CameraType.Scriptable
until Camera.CameraType == Enum.CameraType.Scriptable
	Camera.CFrame = workspace.CameraPart.CFrame
	script.Parent.MouseButton1Click:Connect(function()
		script.Parent.Parent.Parent.Frame.Visible = false
			end)
	
	end)
	
	
	
	end)

2 answers

How about try doing this code:

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local ToNormal = false

script.Parent.MouseButton1Click:Connect(function()
	if ToNormal == false then
		ToNormal = true
		script.Parent.Parent.Parent:WaitForChild("Frame").Visible = true
		repeat
			wait()
			Camera.CameraType = Enum.CameraType.Scriptable
		until Camera.CameraType == Enum.CameraType.Scriptable
		Camera.CFrame = workspace.CameraPart.CFrame
	elseif ToNormal == true then
		ToNormal = false
		script.Parent.Parent.Parent.Frame.Visible = false
		-- then the rest of the code in your second function here
	end
end)

Hope this helps!

If you wanted to set the camera back to deafult, you would neet so set the Camera Subject to the Humanoid, the Camera Type to Custom and the Camera CFrame to the player's head CFrame.

Here is an example:

local Camera = workspace.CurrentCamera
local Player = game:GetService("Players").LocalPlayer


script.Parent.Mouse1ButtonClicked:Connect(function()
	Camera .CameraSubject = Player.Character.Humanoid
        Camera.CameraType = "Custom"
        Camera.CFrame = Player.Character.Head.CFrame
end)

Let me know if this helped you!

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