I made an intro cutscene. Heres the code inside starterplayerscripts:
local TweenService = game:GetService("TweenService")
local camera = game.Workspace.Camera
local cutscenetime = 24
local tweenInfo = TweenInfo.new(
cutscenetime,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
function tween(part1,part2)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = part1.CFrame
local tween = TweenService:Create(camera, tweenInfo, {CFrame = part2.CFrame})
tween:Play()
game.Players.LocalPlayer.PlayerGui:WaitForChild("Intro").Holder.PlayFrame.Play.MouseButton1Click:Connect(function()
wait(0.5)
tween:Cancel()
camera.CameraType = Enum.CameraType.Custom
end)
end
repeat
wait()
until game:IsLoaded()
game.ReplicatedStorage.Events:WaitForChild("SetWalkSpeedEvent"):FireServer(0,0)
tween(game.Workspace.Camera_1, game.Workspace.Camera_2)
For some reason it doesn’t always set the cameratype to scriptable. Instead it stays custom and i get this warning “ActivateCameraController did not select a module”. The cutscene still plays although the cameratype is still custom because of the bug. However, mostly it works fine but sometimes it doesn’t. How do I fix this?
I’ve explained this a couple of times before, but my assumption is that the script is instantly guessing that there’s already a Camera object inside the game, so it’s assuming that there’s also a ActivateCameraController Module inside, but in all reality the script fires way too quick (At the point of impact where the Camera doesn’t even create in time)
An alternate fix would be just to add a simple wait() before you set the CameraType to Scriptable (Cause for some reason that works)
You need to use a RenderStepped event to keep the workspace.CurrentCamera attached to the part when you tween, you also shouldn’t worry too much about that warning.
But it’s not only the warning, it also doesn’t change the cameratype when I get this warning so after the cutscene it would teleport the camera back to the players head although I didn’t script it like that.
Do as @JackscarIitt said, do a Wait() before you set the cameratype, that works because Wait() waits for task schdueler’s next cycle, so the next cycle you would be able to set the camera type. And I highly recommend you use RunService.RenderStepped to keep the camera’s CFrame to that invisible part you have, and once the tween is done, you just disconnect the RenderStepped like this:
local runService = game:GetService("RunService")
local Camera = workspace.CurrentCamera
local Part = workspace.part1
local Stepped
Stepped = runService.RenderStepped:Connect(function()
Camera.CFrame = bCam.CFrame
end)
--Finish your tween then disconnect like this:
Stepped:Disconnect()
Thank you! But for some reason adding the wait() only works in studio. When I joined the game I still got the warning. Is there another way to make the cutscene play when a player joins? Is there a way to check if the camera is loaded correctly?
I tried a RenderStepped event in a different local script (also in the StarterPlayerScripts) and it fired even before the tween function started. In the tween script I used repeat wait until game:IsLoaded() but why isn’t the camera loaded then? Is RenderStepped the only way to detect if the client fully loaded?
As @Vaschex said, this is just an issue with the core camera scripts. It doesn’t actually affect your game in any way and it’s ok to ignore it. Basically the core camera script is just freaking out because it doesn’t have a module to handle the Scriptable camera type (which is the whole point).
The thing is whenever I get this error, the CFrame of the camera will go back to the players head after the tween finished, although I didn’t script it like that. It’s because whenever I get this error, the cameratype doesn’t change to scriptable even though I scripted it so that it should change to scriptable.