Wait, might have figured.
The event PlayerAdded fires before the player spawns into the game and runs the LocalScript.
Which is why it wont work.
Wait, might have figured.
The event PlayerAdded fires before the player spawns into the game and runs the LocalScript.
Which is why it wont work.
How? It is in StarterPlayerScripts and the function connects after the character has been detected.
PlayerAdded referes to Player
in service Players
.
The event fires but the LocalScript has not loaded in yet, it only does afterwards.
As stated in the DevHub:
This event does not work as expected in solo mode , because the player is created before scripts that connect to PlayerAdded run. To handle this case, as well as cases in which the script is added into the game after a player enters, create an OnPlayerAdded function that you can call to handle a player’s entrance.
So he just needs to change PlayerAdded to OnPlayerAdded?
Wait, I did something. Now the player’s camera is not moving at all
1 step closer I guess?
This is the current message I’m getting. I’ve tried to use ReplicatedStorage:WaitForChild("TEST_Camera").Frames
but that doesn’t work either.
Shouldn’t it be game.ReplicatedStorage.MoonAnimatorExports.TEST_Camera.Frames
?
That is at least what it was in your previous code.
Can you show the explorer/path to the TEST_Camera
Yeah sure, hold on.
This is the path to the folder, I’ve pathed it like this:
Game>ReplicatedStorage>TEST_Camera>Frames
The message I’m getting is "Frames is not a valid member of Folder “ReplicatedStorage.Test_Camera.Frames”.
I’ve added Wait(5)
to wait for the loading screen to go away before the cutscene plays.
This is the current script after being modified slightly:
local RunService = game:GetService("RunService")
local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local Camera = workspace.Camera
function Cinematic()
local CinematicsFolder = game.ReplicatedStorage.TEST_Camera.Frames
local CurrentCameraCFrame = workspace.CurrentCamera.CFrame
Camera.CameraType = Enum.CameraType.Scriptable
local FrameTime = 0
local Connection
Connection = RunService.RenderStepped:Connect(function(DT)
local NewDT = DT * 60
FrameTime += NewDT
local NeededFrame = CinematicsFolder.Frames:FindFirstChild(tonumber(math.ceil(FrameTime)))
if NeededFrame then
Character.Humanoid.AutoRotate = false
Camera.CFrame = NeededFrame.Value
else
Connection:Disconnect()
Character.Humanoid.AutoRotate = true
Camera.CameraType = Enum.CameraType.Custom
Camera.CFrame = CurrentCameraCFrame
end
end)
end
wait(5)
Cinematic()
It seems like you trying to find an object named Frames
inside of TEST_Camera.Frames
If that was an accident, change the code like following:
local NeededFrame = CinematicsFolder.Frames:FindFirstChild(tonumber(math.ceil(FrameTime)))
-- If the CinematicsFolder.Frames was not intended, change it to following:
local NeededFrame = CinematicsFolder:FindFirstChild(tonumber(math.ceil(FrameTime)))
It works like a charm. I’ve been searching for a solution to this for so long, Thank you so much!