0 votes
extends Node

onready var player = "res://entities/player.tscn"

enum{
ARGINT,
ARGSTRING,
ARGBOOL,
ARGFLOAT
}

const validcommands = [
["setspeed",
[ARG_FLOAT] ]
]

func _ready():
pass

func set_speed(movespd):
movespd = float(movespd)

if movespd >= 1 and movespd <= 5:
    player.movespd = movespd
    return str("success", movespd)
return("set lower")
in Engine by (12 points)
edited by

1 Answer

+1 vote

I assume you intended to create an instance of that player scene, but you haven't done that. So, right now, your player variable is simply a string containing a path to a scene. And, since a string doesn't have a movespd property, that causes your error.

I'd assume you're trying to do something like this:

onready var player_scene = preload("res://entities/player.tscn")
var player

func_ready():
   player = planer_scene.instance()

With that, player is now an instance of the player _scene. So, assuming that scene has a script attached that provides the referenced movespd property, that should fix your error.

by (10,856 points)
edited by

Yep, likely still a PackedScene.

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 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 webmaster@godotengine.org with your username.