☑ Calling a function inside a script

Hello, maybe i’m doing something wrong, i try to call a function inside a script (function is in the same script) and i use this.functionName() but it say that is not a function…i think i’m going senile…where i do wrong?

post the script, that must have be some sintax error

1 Like

How on earth could anyone know what’s wrong without looking at the code?? :smiley:


a sintax! it we start taxing people for their sins where will it all end ?

1 Like

syntax*, sorry for my english

:stuck_out_tongue: sorry, since that line didn’t seem to work but calling it from another script it does work i just added an if statement and solved my problem …deepest apologizes

ok seems my solution was not doable so i post here the function and how i call it

closeShop: function(){
    this.isOpen = false;

called by this.closeShop()

ps this is the project https://playcanvas.com/editor/scene/396696 and the script is Shop.js

This appears to be another misunderstanding of the ‘this’ keyword.

You call closeShop like this:


It should either be:



            var self = this;

The latter is a bit more optimal.

:slight_smile: feel stupid…sigh…sorry for the bother and thanx a lot @will

1 Like