Hello,
I've written some sort of an intro sequence program to put the player through a series of sections before returning the camera to the avatar. The First one is merely just a title screen, while the second is a character customization menu. A TextButton named PlayButton s responsible for these transitions, and actively keeps track of which scene it's on, depending on the scene, it'll move to the next appropriate section. Let's say if I were on the customization menu, it would know to return me to the player after I've finished. This all works marvelously, except for a feature I added recently.
When the player dies, it's supposed to skip the title sequence and bring them back to the customization menu automatically, and then again, return the camera, however, this is where it goes wrong. It sets back to the player fine, until I reset my character and go back to the customization menu to return once again to the avatar. Once I click the button, it switches back, but the camera isn't following the player anymore like before, it merely just sit's on the ground, and I can move around with it in some sort of a way you would with the Studio camera.
I've tried multiple different patches, all came to no avail, I am really at a loss, I was wondering if anyone could help me understand why this is occurring.
Here is the Script: Local, under a ScreenGui.
local Camera = {
workspace.TitleView, workspace.CustomizationView
};
local CameraMain = workspace.CurrentCamera
local CurrentCamera
local Player = game:GetService("Players").LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local MenuGui = PlayerGui:WaitForChild("MenuGui")
local Frame = MenuGui:WaitForChild("Frame")
local PlayButton = Frame:WaitForChild('PlayButton'); local Clicked
local Character = Player.Character or Player.CharacterAdded:Wait()
local RootPart = Character:WaitForChild("HumanoidRootPart")
local Humanoid = Character:WaitForChild("Humanoid")
local function SetCamera(Camera, CameraPoint, SetInOutFade)
local CamType = Camera and Enum.CameraType.Scriptable or Enum.CameraType.Custom
local CamCFrame = CameraPoint.CFrame
if not (SetInOutFade) then
for FadeIn = 1,0,-.01 do wait(.001)
Frame.BackgroundTransparency = FadeIn
end
spawn(function()
for FadeOut = 0,1,.01 do wait(.001)
Frame.BackgroundTransparency = FadeOut
end
end)
end
CameraMain.CameraType = CamType
CameraMain.CameraSubject = CameraPoint
CameraMain.CFrame = CFrame.new(CamCFrame.p)
Clicked = false
return CameraPoint
end
SetCamera(true, Camera[1], true) --// Title Sequence Once
PlayButton.MouseButton1Down:Connect(function() if (Clicked) then return end Clicked = true
if (CurrentCamera ~= Camera[2]) then
CurrentCamera = SetCamera(true, Camera[2]); PlayButton.Text = "READY"
return end ChangeAudio(nil, true)
SetCamera(false, RootPart); PlayButton.Parent = nil --// Set back to player line
Humanoid.Died:Connect(function()
SetCamera(true, Camera[2]); PlayButton.Parent = MenuGui
end)
end)
This script is quite large and a bit complicated, If there is anything you need me to clarify I'll be ready to explain! Thanks in advance, your help is extremely appriciated.
The fade-in-out is just a blackout transition if you were wondering.
