Ok, here is a example of what you are saying.
Code on:
(Look bottom right)
Code off:
(Look bottom right)
Ok, here is a example of what you are saying.
Code on:
Code off:
no, should i have the script disable the object, Not vice versa
No or else the script wonāt work.
so i disable the script on the item?
No. Your making me get a headache
im sorry, im very new, before i started this iāve NEVER coded before
I think Iām giving everyone headaches lol
1 last question, iāve been working on the hotbar switch, and i ran into a problem.
i have my flashlight out and i can still shoot.
If you donāt tell the shooting part of your code that the player is using the flashlight and not the pistol, the shooting part of your code will still do is job. You have to add an if statement to check if the pistol is enabled. Below an example. Be aware that the code I show you is just to give you an idea. The code is not optimized.
if (this.app.root.findByName(āPistolā).enabled === true) {
// shooting code
}
can i try it?
Yes thatās why I sent it of course.
it shows an error and now it doesnāt shoot, not even for the gun
this the code
if (this.app.root.findByName('Pistol').enabled === true) {
// shooting code
Movement.prototype.onMouseDown = function(event) {
if (event.button === pc.MOUSEBUTTON_LEFT) {
// shoot
if (this.rounds !== 0) {
var bullet = this.app.root.findByName('Bullet').clone();
this.app.root.addChild(bullet);
bullet.reparent(this.app.root);
bullet.setPosition(this.app.root.findByName('Bullet').getPosition());
bullet.setRotation(this.app.root.findByName('Bullet').getRotation());
bullet.enabled = true;
console.log(bullet);
// update magazine
this.rounds = this.rounds - 1;
}
}
};
}
Because you placed the code outside the function.
// Function start (recognizable by the script name)
Movement.prototype.onMouseDown = function(event) {
// Function end
};
wait im confused, do i do this
// Function start (recognizable by the script name)
Movement.prototype.onMouseDown = function(event) {
if (this.app.root.findByName('Pistol').enabled === true) {
// shooting code
Movement.prototype.onMouseDown = function(event) {
if (event.button === pc.MOUSEBUTTON_LEFT) {
// shoot
if (this.rounds !== 0) {
var bullet = this.app.root.findByName('Bullet').clone();
this.app.root.addChild(bullet);
bullet.reparent(this.app.root);
bullet.setPosition(this.app.root.findByName('Bullet').getPosition());
bullet.setRotation(this.app.root.findByName('Bullet').getRotation());
bullet.enabled = true;
console.log(bullet);
// update magazine
this.rounds = this.rounds - 1;
}
}
};
}
// Function end
};
No of course not. Just replace the if statement inside the fuction.
// Function start (recognizable by the script name)
Movement.prototype.onMouseDown = function(event) {
if (this.app.root.findByName('Pistol').enabled === true) {
// shooting code
if (event.button === pc.MOUSEBUTTON_LEFT) {
// shoot
if (this.rounds !== 0) {
var bullet = this.app.root.findByName('Bullet').clone();
this.app.root.addChild(bullet);
bullet.reparent(this.app.root);
bullet.setPosition(this.app.root.findByName('Bullet').getPosition());
bullet.setRotation(this.app.root.findByName('Bullet').getRotation());
bullet.enabled = true;
console.log(bullet);
// update magazine
this.rounds = this.rounds - 1;
}
}
}
// Function end
};
what is intense?
do i just copy it?
Yes @thebosser24, what else?
ok
OMGOSH, It works, @Albertos @Gabriel_Dobrzynski @Leonidas @yaustar
Your all the best, kudos to you for all the help you gave me