Infinite yield problem

I was trying to make a variable to reach the part “Engine” but for some reason I keep getting the Infinite yield warning. My game doesn’t lag and Engine is a child of Model, Anyone know how to fix it?

Code:

local engine = script.Parent.Parent.Parent:WaitForChild('Engine')

Explorer tab:
image

1 Like

In which script is this line of code located?

1 Like

The local script, sorry I forgot to say

1 Like

LocalScripts aren’t going to run in a model in Workspace, are they?

1 Like

Can you show the contents of the server script that is the local script’s parent? I think I might know what the problem is if my assumptions are right.

1 Like

They should work any where that can be replicated to client or server (which it is)

1 Like

Your local script is disabled bro and even then they dont replicate on the workspace. The reason it does not run on the workspace is cause the workspace is the renderer, it processes data on the server. Now I will say your character is treated as a user data so running the local script under the parent of your character data model will work

2 Likes

He’s using an outdated method for replicating the localscript to the client whenever they sit on the vehicleseat. I’d recommend using remotes for that, but in theory this should work.

3 Likes

If you are saying that they do not replicate to the server in workspace, add that he can use remote events to fix that.

1 Like

I dont understand why its outdated, I use the paradigm for my vehicle scripts I just replicate them to the player scripts instead

1 Like

He’s replicating it in real time whenever the occupant changes. This isn’t a good practice compared to just using remotes.

As for the original post, the problem is that you’re changing the parent of the LocalScript to the Player (or a container where the LocalScript can run), meaning the previous hierarchy of the model is an outdated reference.

Can you post the error so I can confirm this?

4 Likes

it simply is inefficient compared to using remotes

3 Likes

Well I have encountered no memory leaks so I mean could you elaborate on this?

1 Like

Not leaking memory doesn’t mean it’s efficient lol. The practice of “dropping” LocalScript’s into the client pre-dates FilteringEnabled by many, many years. Why rely on old methods when there’s easier ways to do it?

1 Like

I see now, I forgot that players change the parent so I’m going to use remotes and see if that works

3 Likes

Simply not being taught about it, i’ll look into it tonight. Thank you.

1 Like