jx_0sh
(jx_0sh)
December 30, 2021, 10:19pm
1
I’ve got this line of code in a local script inside a GUI in StarterGui.
local campart = workspace.CARSPAWNINGPREVIEW.camerapart
However, for some reason it can not find the camerapart and keeps returning with
22:13:53.918 camerapart is not a valid member of Folder "Workspace.CARSPAWNINGPREVIEW" - Client - sc:4
22:13:53.918 Stack Begin - Studio
22:13:53.919 Script 'Players.socixlizr.PlayerGui.CarSpawning.sc', Line 4 - Studio - sc:4
I’ve tried a waitforchild, and ensured it is also where I am calling it to be.
4 Likes
iBuzzes
(Ryry)
December 30, 2021, 10:26pm
2
You should use Instance | Roblox Creator Documentation to wait for the instance to exist in case the instance does not exist yet when called.
local campart = workspace:WaitForChild("CARSPAWNINGPREVIEW"):WaitForChild("camerapart")
2 Likes
jx_0sh
(jx_0sh)
December 30, 2021, 10:26pm
3
Already tried that, it finds the folder but then can’t find the part.
iBuzzes
(Ryry)
December 30, 2021, 10:29pm
4
Did you use WaitForChild in the part as well?
jx_0sh
(jx_0sh)
December 30, 2021, 10:30pm
5
I done exactly what you done then it infinite yielded at finding camerapart.
wf_sh
(wait)
December 30, 2021, 10:43pm
6
Can you shove this in your script and tell us what it prints?
for _,v in pairs(Workspace.CARSPAWNINGPREVIEW:GetChildren()) do
print(v)
end
4 Likes
NyrionDev
(Nyrion)
December 30, 2021, 10:45pm
7
Are you sure the part exists while the simulation runs? also are you sure it’s exactly named “camerapart” without any hidden characters like a space?
use FindFirstChild to return if the script found the object or not
local campart = workspace.CARSPAWNINGPREVIEW:FindFirstChild(“camerapart”)
if campart then
–code
end
jx_0sh
(jx_0sh)
December 30, 2021, 11:11pm
9
For some reason it doesn’t find the parts but only finds the folders and models.
Make sure you haven’t named a Folder or something the same as the part.
jx_0sh
(jx_0sh)
December 30, 2021, 11:13pm
11
You can see the explorer there.
My bad. Have you tried FindFirstChild()?
jx_0sh
(jx_0sh)
December 30, 2021, 11:14pm
13
I tried a WFC and it didn’t do anything.
wf_sh
(wait)
December 30, 2021, 11:15pm
14
Its quite obvious then that to the script, those parts dont exist. Are these parts being interfered with any other scripts running on the client?
1 Like
jx_0sh
(jx_0sh)
December 30, 2021, 11:17pm
15
Nope, the parts are only called for in that script, and the parts are there in game as you can clearly see.
Is the camerapart’s archivable property set to true?
1 Like
jx_0sh
(jx_0sh)
December 30, 2021, 11:22pm
17
Affirm. Yes it is, and it is anchored and collidable.
local camerapart = workspace.CARSPAWNINGPREVIEW.camerapart or workspace:WaitForChild("CARSPAWNINGPREVIEW"):FindFirstChild("camerapart")
Try this. I’m just thinking of possible ways and it probably won’t work but it’s worth a try.
jx_0sh
(jx_0sh)
December 30, 2021, 11:34pm
19
Tried both ways, neither of them work.
wf_sh
(wait)
December 30, 2021, 11:34pm
20
Interesting, after looking more closely I noticed that it prints the names of ‘Model’ and ‘PREVIEW’ which are then hyphenated with Client trailing after despite have a green line next to them, indicating it is being outputted by the server.