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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago

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!

Ad
Log in to vote
0
Answered by 4 years ago

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!

Answer this question