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

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

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)

1 comment

0

Set the camera's CameraSubject to the players head and set the camera's type to custom

1 answer

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

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