Game says part isn't there yet it is?

Part of my UI relies on cutscenes. I tested the UI in a seperate place, where it worked completely fine, and when finished I put it into the main game, however now it doesn’t work and throws errors.
I tested my game for viruses twice, and even then I haven’t even used free models other than a gun kit, and I went through each of my scripts.
I honestly have no idea why this is happening and I’ve been pulling my hair out for about 3 hours trying to figure out why it works in one place and not the other… :upside_down_face:

In this screenshot, you’ll see it says script ‘Players.FragmentFour.PlayerGui.MenuUi.UiScript, on line 15’

“Scene1-2 is not a valid member of Folder”
However in the following screenshots you’ll see this definitely isnt’ the case.

image

Here’s my code:

local CamTweenInfo = TweenInfo.new(24, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)

local BackTweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)

local Scene1Anim = TweenService:Create(Camera, CamTweenInfo, {CFrame = MenuCutsceneParts["Scene1-2"].CFrame, Focus = MenuCutsceneParts.Scene1Focus.CFrame})

local Scene2Anim = TweenService:Create(Camera, CamTweenInfo, {CFrame = MenuCutsceneParts["Scene2-2"].CFrame, Focus = MenuCutsceneParts.Scene2Focus.CFrame})

local Scene3Anim = TweenService:Create(Camera, CamTweenInfo, {CFrame = MenuCutsceneParts["Scene3-2"].CFrame, Focus = MenuCutsceneParts.Scene3Focus.CFrame})

local SceneTransition1 = TweenService:Create(UI.Background, BackTweenInfo, {BackgroundTransparency = 0})

local SceneTransition2 = TweenService:Create(UI.Background, BackTweenInfo, {BackgroundTransparency = 0.8})

--// Module Code

Here is where I referenced "MenuCutsceneParts"

local TweenService = game:GetService("TweenService")

local StarterGui = game:GetService("StarterGui")

local PlayerGui = player:WaitForChild("PlayerGui")

StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)

PlayerGui:SetTopbarTransparency(1)

local UI = script.LoadingUi

UI.Parent = PlayerGui

local Label = UI.TextLabel

repeat wait() until game:IsLoaded()

workspace.Regions.Ambience.Played:Connect(function()

workspace.Regions.Ambience.Volume = 0

workspace.Regions.Ambience:Stop()

end)

local Camera = workspace.CurrentCamera

local MenuCutsceneParts = workspace:WaitForChild("MenuCutsceneParts")

At the begining of the script do

wait(1)

Your script doesn’t have any thing in it concerning “Scene1-2”? Could you elaborate about the problem?

2 Likes

Wherever you index the folder, change Folder["Scene1-2"] to Folder:WaitForChild("Scene1-2"). You didn’t post the code where the actual error is, so it’s hard to say why it doesn’t exist yet, but it seems like it hasn’t fully loaded in yet. This makes sense for the main place which probably has more other stuff in it, which is why it works in one and not the other.

3 Likes

Sorry, I updated my post to include the code

1 Like

That’s not where you reference Scene1-2, which is what the error is. What’s at line 46? Are the parts created by a script?

3 Likes

Everything is already in workspace.
–// Camera Tween Code

local CamTweenInfo = TweenInfo.new(24, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)

local BackTweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)

local Scene1Anim = TweenService:Create(Camera, CamTweenInfo, {CFrame = MenuCutsceneParts["Scene1-2"].CFrame, Focus = MenuCutsceneParts.Scene1Focus.CFrame})

local Scene2Anim = TweenService:Create(Camera, CamTweenInfo, {CFrame = MenuCutsceneParts["Scene2-2"].CFrame, Focus = MenuCutsceneParts.Scene2Focus.CFrame})

local Scene3Anim = TweenService:Create(Camera, CamTweenInfo, {CFrame = MenuCutsceneParts["Scene3-2"].CFrame, Focus = MenuCutsceneParts.Scene3Focus.CFrame})

local SceneTransition1 = TweenService:Create(UI.Background, BackTweenInfo, {BackgroundTransparency = 0})

local SceneTransition2 = TweenService:Create(UI.Background, BackTweenInfo, {BackgroundTransparency = 0.8})
1 Like

That’s weird, is it possible your Scene1-2 part has special characters in its name? Try selecting it in the explorer and typing print(game.Selection:Get()[1].Name), then directly pasting that between the quotes for that tween.

If not, the problem could be multiple folders named MenuCutsceneParts. Double-check to make sure you don’t have any in workspace, and check what is a child of MenuCutsceneParts in the script. (Just loop through its children and print their names.)

3 Likes

I’ve tried that, and I’ve tried even renaming the folder to something else and referencing it.
The weirdest part is this works completely fine in the place where I first created the script, so I honestly don’t think it’s that.

Did you try printing the children? It could be something weird relating to them not replicating properly, but I’m really not sure what’s going on here.

Also, you might want to try using MenuCutsceneParts:WaitForChild("Scene1-2") like I suggested earlier, which really shouldn’t be the solution but might work.

3 Likes

I tried printing the children, I think you’re right about it not replicating properly because here is what happened
image

image

:thinking:

1 Like

That’s really weird, are you deleting parts on the client? It seems like you have something that destroyed them, so maybe another script is interfering.

3 Likes

Are you using WaitForChild on MenuCutsceneParts? ReplicatedFirst scripts run far before the server finishes replicating the DataModel snapshot to the client. The only case in which you would be getting this error is if you aren’t using WaitForChild.

What does your code currently look like as well? To my understanding, there’s been changes between now and when you originally posted this help request wherein WaitForChild wasn’t being used on top-level workspace items (immediate children of the workspace, such as the MenuCutsceneParts folder).

1 Like

The original code was in PlayerGui, I think the ReplicatedFirst code was just to check what the children were as a test.

3 Likes

You’re right, the original code is in playergui, however even then I’m using waitforchild for both the folder and the cutscene parts

@DevConX A wait at the beginning of a script is a code smell. Don’t do this, ever. You should never have a reason to use wait at the beginning of any script.

@posatta Oh? I don’t know why a test would be put in ReplicatedFirst, but alright. Would still be nice to see the current code in question (the one actually experiencing the issue) and hierarchy of everything involved to further understand the problem at hand.
(cc @FragmentFour)

1 Like

Here’s the part of the code that’s giving me trouble:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local TweenService = game:GetService("TweenService")

local Players = game:GetService("Players")

local StarterGui = game:GetService("StarterGui")

local PlayerGui = Players.LocalPlayer:WaitForChild("PlayerGui")

local player = Players.LocalPlayer

local TeamsTablesModule = require(script.Parent.TeamsModule.TeamsTablesModule)

local Camera = workspace.CurrentCamera

local BlockMainFrame = UI.BlockMainFrame

local BlockFrame = BlockMainFrame.BlockFrame

local BlockLabel = BlockMainFrame.BlockLabel

local PlaySpawnEvent = ReplicatedStorage.PlaySpawnEvent

local MenuCutsceneParts = workspace:WaitForChild("MenuCutsceneParts")

local KeepPerformingCutscene = false

local BackgroundMusic = script.Parent.Parent.BackgroundMusic

local MenuActivated = ReplicatedStorage.MenuActivated

--// Tween Code

local SizeTweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)

local Entrance1Anim = TweenService:Create(BlockFrame, SizeTweenInfo, {Size = UDim2.new(1, 0, 0.02, 0)})

local Entrance2Anim = TweenService:Create(BlockFrame, SizeTweenInfo, {Size = UDim2.new(1, 0, 1, 0)})

local Exit1Anim = TweenService:Create(BlockFrame, SizeTweenInfo, {Size = UDim2.new(1, 0, 0.02, 0)})

local Exit2Anim = TweenService:Create(BlockFrame, SizeTweenInfo, {Size = UDim2.new(0, 0, 0.02, 0)})

local TextTransparencyTI = TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)

local TextOnAnimation = TweenService:Create(BlockLabel, TextTransparencyTI, {TextTransparency = 0})

local TextOffAnimation = TweenService:Create(BlockLabel, TextTransparencyTI, {TextTransparency = 1})

--// Camera Tween Code

local CamTweenInfo = TweenInfo.new(24, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)

local BackTweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0)

local Scene1Anim = TweenService:Create(Camera, CamTweenInfo, {CFrame = MenuCutsceneParts:WaitForChild("Scene1-2").CFrame, Focus = MenuCutsceneParts.Scene1Focus.CFrame})

local Scene2Anim = TweenService:Create(Camera, CamTweenInfo, {CFrame = MenuCutsceneParts:WaitForChild("Scene2-2").CFrame, Focus = MenuCutsceneParts.Scene2Focus.CFrame})

local Scene3Anim = TweenService:Create(Camera, CamTweenInfo, {CFrame = MenuCutsceneParts:WaitForChild("Scene3-2").CFrame, Focus = MenuCutsceneParts.Scene3Focus.CFrame})

local SceneTransition1 = TweenService:Create(UI.Background, BackTweenInfo, {BackgroundTransparency = 0})

local SceneTransition2 = TweenService:Create(UI.Background, BackTweenInfo, {BackgroundTransparency = 0.8})

And here’s the hierarchy

image

Might be an issue with your implementation. I had no errors after throwing this code into a LocalScript with a dummy Gui to help make the code work. One small change I did make was to comment out the TeamsModule require and use WaitForChild on the background music.

CodeTester.rbxl (23.3 KB)

What current errors are you receiving and what’s the hierarchy of your Gui? What’s the problem that’s currently occurring? I want to set all the details of the issue straight first or go over what’s known before continuing. Again, things may have changed since this thread was first posted.

1 Like

I figured it out, very simple solution… streamingEnabled was on, which made the parts not render on the client… therefore they didn’t exist to the client. This is why it worked in the test game.
Thank you for helping me with this though, I don’t think I would’ve figured it out myself. :woman_facepalming: :woman_facepalming:

3 Likes

Ooh! So it was an external problem. Yep, StreamingEnabled would definitely cause the nonexistence of the parts. Bummer. You can still salvage this issue though.

Often at times, I also use this same solution of setting up parts for scene views because I don’t want to do any CFrame work or anything. It’s way easier for a lazy person like me to just put down parts and change the camera CFrame to them. Very, very simple.

To ensure that my parts don’t just get demolished or StreamingEnabled doesn’t rip them out of the workspace, I actually put them in ReplicatedStorage. Yep, that works. When you’re done setting up your scenes, just stuff the folder of parts in ReplicatedStorage. StreamingEnabled won’t stream them out. Just reference the CFrames of the parts and you’re good as gold.

4 Likes