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

How do I make the camera revert back to normal after a player presses play?

Asked by 3 years ago

I want to make a camera tween for my main menu. When I click the play button, it’s supposed to stop the tween in the background and reset back to the player camera. This is the part that breaks. I’ve tried changing the camera enum value to fixed, changing the camera to the player, and so on. None of these have worked. https://streamable.com/ntagut Code:

--Camera
local player = game.Players.LocalPlayer
local cutsceneTime = 25
local character = player.Character or player.CharacterAdded:Wait()

local camTweenInfo = TweenInfo.new(
    cutsceneTime, 
    Enum.EasingStyle.Sine,
    Enum.EasingDirection.Out,
    120, 
    true,
    5
)
function camTween()
        character:WaitForChild("Humanoid")
        local tween = tweenService:Create(cam, camTweenInfo, {CFrame = camPart2.CFrame})
        tween:Play()
end

--Main
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = camPart.CFrame
wait(3)
tweenDestroyLoadScrn:Play()
wait(0.5)
main.Visible = true
tweenPlayBtn:Play()
tweenGameIcon:Play()

PlayBtn.MouseEnter:Connect(function()
    tweenEnterPlayBtn:Play()
end)
PlayBtn.MouseLeave:Connect(function()
    tweenLeavePlayBtn:Play()
end)


PlayBtn.MouseButton1Click:Connect(function()
    tweenStartMain:Play()
    gameIcon:Destroy()
    PlayBtn:Destroy()
    wait(2)
    tweenDoneMain:Play()
    cam.CameraType = Enum.CameraType.Custom
    cam.CameraSubject = player
    wait(2)
    loadingScrn:Destroy()
    main:Destroy()

end)

print("Hi")

camTween()
--wait(cutsceneTime)
0
Set the camera's CameraSubject to the players head and set the camera's type to custom 3F1VE 257 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

I fixed it by taking the taking out the contents of the camTween() function and using the TweenName:Cancel function.

Ad

Answer this question