So Basically ive been seeing an error message pop up in my Output when I clone a model from lighting and place it in Workspace, saying
"Part is not valid member of Model"
the error happens in a RenderStepped function and the error message happens almost as soon as the model is parented to workspace. Which makes me think maybe it hasn’t loaded in as quick as the model has if that makes sense? So I put a Model:WaitForChild(“Part”) instead of Model.Part. But then in InfiniteYield Possible message comes up.
So now im really confused because i check the explorer and the Model does have a Part inside it (ClientSide and ServerSide so its definatly there) but the code keeps breaking because its not detecting the Part inside the Model.
This is some example code from the game showing parts of code from a client and server script
---Everythings just named for simplicitys sake
-- There is a model in lighting called Model which include one part called "Part"
-- There is a Folder in Workspace called Folder
-- There is a Folder Called RemoteEvents that includes 2 Remoted events called, "CloneModelFromLighting" and "RemoveModelFromFolder"
-- Server script located in Workspace
-- Client Script located in StarterPlayerScripts
--Client
game:GetService("RunService").RenderStepped:connect(function() -- This function just fires repeatedly as quick as possible
local Models = game.Workspace.Folder:GetChildren()
for i = 1,#Models do
print(Models[i]:WaitForChild("Part").Name) -- The problem is it cant detect the Part EVEN THOUGH ITS THERE
end
end)
--Server
--this is just here to show that the folder is Removing and adding models throught the game
game.ReplicatedStorage.RemoteEvents.CloneModelFromLighting.OnServerEvent:Connect(function()
game.Lighting.Model:clone().Parent = game.Workspace.Folder
end)
game.ReplicatedStorage.RemoteEvents.RemoveModelFromFolder.OnServerEvent:Connect(function(Model) -- Model is a Model that Client wants to remove from folder
Model:Destroy()
end)
This problem isnt just for this client script.
its also a problem for just server scripts so its not an FE problem
So my question is why am I having problems detecting a Part if its definitely there?
For cloning purposes like mentioned above: I would take things from ReplicatedStorage instead. As a question, why Lighting? (I’m not sure if this would fix it, or if it’s something im missing)
That’s the first thing I thought. but I’ve been using lighting to store for so long now its just a bad habit.
I learned from using a lot of premade codes from toolbox and a lot of them used lighting to store.
It would take days to have everything taken from ReplicatedStorage so unless its definitely a lighting problem id rather not change it lol
But if its a lighting problem why is it a lighting problem. Is it Not loading the parts inside the model quick enough to workspace? if that’s the case then surely the Infinite Yield Possible message wouldn’t display?
Like I said; I don’t know if it really is a Lighting problem.
I’ve only used lighting for about one thing, individual part cloning, for humanoid effects similar to infection style things.
May i ask why you are making a table of Model instances and searching each for the part? Maybe just have something send the literal instance to the client, and then RenderStepped just reading that model?
And basically the rendered step function is looking too see which model the camera is closest too and firing an event for the server to update if the closest model has been changed.
but when a new room has been added to the folder. the rendered step function breaks like 1-3 times but works after that? its kind of weird.
so i cant just send the literal instance to the client because the camera is client based so only the client knows what the closest model is to send to the server. but its not detecting the Primary part inside the model that it can measure the magnitude from
What you could to is fire a BindableEvent to the sever to return the CFrame of the part, then create one there on the client. Wouldn’t solve the problem, but instead go around it.
I have this problem with multiple Scripts so I don’t want to make a mess with blindable events…
I’m kind of hoping that there’s a solution that will fix it and i don’t have to worry about it if I have to reference it again in the future. cause I keep a lot off different models in the lighting space that it might happen too as well.
Thanks for the suggestion though means a lot. I really need the help cause I have no clue at this point
I think he means “hierarchy”, or (in other words) your explorer widget.
When this happens, I put print(<error.Parent>:GetChildren(), <error.Parent>.Name) to see where this is going wrong.
I think its because Lighting may (?) not be able to store BaseParts, because thats why it says Can't find Part, not Cant Find Model. I know that putting 2 skyboxes automatically deletes the other, maybe this is the same problem? You could check if the part is still there ingame. If not, try putting it in the repStorage.
You can use the Find All/Replace All tool to simplify the process, if needed.
When I test it in studio the Part is defo there, Client Side and Server Side.
(Edit) because its quite an uncommon bug im going to wait until i have spare time after working and ill try to convert everything from lighting to ReplicatedStorage. Ill let you all know how it goes.
Anyone reading this thread know anything else to try please let me know