aiaf Posted May 26, 2019 Share Posted May 26, 2019 To reproduce press A key. When i call world:FindEntity("BoxA"):Hide() on object with no script attached it crashes with: "attempt to index a nil value" BoxB has some script attached and doesnt have this problem. if (window:KeyHit(Key.A)) then world:FindEntity("BoxA"):Hide() end if (window:KeyHit(Key.B)) then world:FindEntity("BoxB"):Hide() end test.map PS im on 4.5 , didnt test on 4.6 but think is the same problem Quote I made this with Leadwerks/UAK: Structura | Stacky Desktop Edition Website: Binary Station Link to comment Share on other sites More sharing options...
Yue Posted May 26, 2019 Share Posted May 26, 2019 World:GetCurrent():FindEntity ("generic"): Hide () I tested this on 4.6 from a script file, and it worked correctly. Quote Link to comment Share on other sites More sharing options...
mdgunn Posted May 27, 2019 Share Posted May 27, 2019 It might not be obvious which thing is nil, which might help understand which link in the command chain went wrong. I would temporarily split each bit into a local assignment and see where the problem occurs. Like this... local currentWorld = world local boxA = currentWorld:FindEntity("BoxA") boxA:Hide() Also be aware that if the item you are trying to find is a prefab it may not find it as it is not an instance and I think I had a situation that it would not find it until I made it an instance. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.