Cutscene script not working

I’m working on a cutscene script that works so that a player can’t move because they will also have a gui. the problem is on line 28 in the local script it says: "PartA is not a valid member of Folder “Workspace.CamParts”. I tried debugging this but it didn’t work.

local script:

local ts = game:GetService("TweenService")

local camera = workspace.Camera

local cutscenetime = 6

local info = TweenInfo.new(
	cutscenetime,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	true,
	0
)

function tween(part1,part2)
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = part1.CFrame

	local tween = ts:Create(camera, info, {CFrame = part2.CFrame})
	tween:Play()

	wait(cutscenetime)

	camera.CameraType = Enum.CameraType.Custom
end
game.ReplicatedStorage.MainMenuActions.OnClientEvent:Connect(function()
	tween(workspace.CamParts.PartA, workspace.CamParts.PartB)
	tween(workspace.CamParts.PartB, workspace.CamParts.PartC)
	tween(workspace.CamParts.PartC, workspace.CamParts.PartD)
end)

Server Script:

game.Players.PlayerAdded:Connect(function(plr)
	game.ReplicatedStorage.MainMenuActions:FireClient(plr)
	plr.CharacterAdded:Connect(function(chr)
		local hum = chr.Humanoid
		hum.WalkSpeed = 0
		hum.JumpPower = 0
	end)
end)

The first step would be to check the explorer, is PartA a child of workspace.CamParts? can you show your explorer in a screenshot?

I fixed it, I just needed to put a task.wait() or wait()

task.wait() works, but there is a more acccurate way of waiting for the cam parts folder to load. Instead of doing task.wait(), call the camera parts with :WaitForChild(). This is what it would it look like

workspace.CamParts:WaitForChild(“PartA”)

This can be done for each camera part.

:WaitForChild() makes sure that the script yields for the shortest time possible.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.