0 votes

Hello everyone,
When encoding this tape:
var newplatform = sceneplatform.instance() as StaticBody2D

an error appears:

invalid.call. nonexistent function "instance" in base"nil"

how to fix the error??

Godot version Godot version 3.4.4
in Engine by (12 points)

1 Answer

+2 votes

This error is telling you that the variable you're calling instance() on is null. Where are you setting the value of scene_platform?

by (22,069 points)

I'm not sure if I understood correctly, but if you mean it:
export (PackedScene) var sceneplatform
if i'm wrong. then please help me how can i get the scene
platform value))

Yes, that's right. Have you assigned a scene to that variable in the Inspector? Because the error is saying that you haven't.

with your help, I can see what the problem is, BIG THANK YOU)
but can you help me fix it?)

Well, you've defined the variable as export meaning it will be visible for you to set a value in the Inspector, so that's what you need to do.

In the Inspector, you can assign the scene you want in a couple of ways:

1) Drag the tscn file from the FileSystem tab and drop it on the variable in the Inspector
2) In the variable in the inspector, click the down arrow (where it says "[empty]" and choose "Load", then choose the scene you want

I tried both options a few times and saved the changes as well
1) scene_platform was still empty
2) after starting the scene, the same problem appears again the exported file disappears from the field

You drag it in there and it stays empty?

Do you have this scene with the exported field instanced somewhere else?

i drag the tscn scene into the field:
Script Variables:
scene_platform [nul]

it is preserved, but the value
scene_platform
in
members
equal to [null]

yes, I have a saved tscn scene, and no, it is not instantiated anywhere else
after restarting the game, the same problem appears and the field-Script Variables:
scene_platform- becomes empty

I feel like I'm missing something in your description. Words are failing us here.

If you zip up your project and send it to me I'd be happy to look at it and see what's going on.

can i send you the whole project file to your email? I'm not sure if it's possible to submit it on this site

That or you can post it on a filesharing site.

It's chris at kidscancode.org

I sent you the zip file of the project by email, if you find the problem, please write back

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.