Part not being found as a valid member of workspace in a LOCAL script

Hello, I am working on a cutscene for my game and I’ve been using a model a friend showed me, I’m having issues with a local script, for some reason part A is in workspace but the Local script cannot detect it, I have not had something like this happen before, I am not sure if Roblox changed something up with Local scripts.

The error occurs when it states (MoveCamera(game.Workspace.PartA)

wait(0)
local TweenService = game:GetService("TweenService")
local Camera = game.Workspace.CurrentCamera

local function MoveCamera(StartPart, EndPart, Duration, EasingStyle, EasingDirection)
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = StartPart.CFrame
	local Cutscene = TweenService:Create(Camera, TweenInfo.new(Duration, EasingStyle, EasingDirection), {CFrame = EndPart.CFrame})
	Cutscene:Play()
	wait(Duration)
end

local function Cutscene()
	MoveCamera(game.Workspace.PartA, game.Workspace.PartB, 9.5, Enum.EasingStyle.Quad,  Enum.EasingDirection.Out)  ---HERES WHERE ERROR OCCURS IT CANNOT DETECT PART IN WORKSPACE ALTHOUGH IT IS THERE
	MoveCamera(game.Workspace.PartC, game.Workspace.PartD, 7, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
	
	wait(.5)
	Camera.CameraType = Enum.CameraType.Custom
	Camera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
end

Cutscene()

Workspace Parts don’t necassarily spawn in at the same time in the client loads. You should do game.Workspace:WaitForChild(“InsertPartName”) so it yields until the part exist, do that with the other parts.

2 Likes

I fixed it, it worked, but now I feel stupid for not realizing that lol, thanks tho

1 Like

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