Hello everyone,
maybe someone can help me with my problem.
I have created a unit named “Dummy”.
I added a recoil tween and also a script that will be executed, when the player attacks this unit.
But it does not work.
mr–beast
Hello everyone,
maybe someone can help me with my problem.
I have created a unit named “Dummy”.
I added a recoil tween and also a script that will be executed, when the player attacks this unit.
But it does not work.
mr–beast
Welcome, mr_beast!
Instead of setting the script to run in the Effects tab of the unit, can you try putting the script in the unit’s entity scripts and adding the ‘when this entity gets attacked’ trigger to it? If you have used the ‘last attacked unit’ function anywhere in the script, replace it with ‘this entity.’
Thanks for your answer.
I removed the settings for running the script from the Effects tab and set the trigger for your script as you said. I also ensured that i dont use ‘last attacked unit’ function.
But at the end it’s not working
Can you show the script that you’re trying to run?
Here is the script as JSON:
{
"triggers": [
{
"type": "entityGetsAttacked"
}
],
"conditions": [
{
"operator": "==",
"operandType": "boolean"
},
true,
true
],
"actions": [
{
"type": "setEntityAttribute",
"attribute": "DMs0olHoap",
"entity": {
"function": "getLastAttackingUnit"
},
"value": {
"function": "calculate",
"items": [
{
"operator": "+"
},
{
"function": "getEntityAttribute",
"attribute": "DMs0olHoap",
"entity": {
"function": "getLastAttackingUnit"
}
},
1
]
}
}
],
"name": "OnAttacked",
"parent": null,
"key": "TJQZtRAKNK",
"order": -1
}
The attribute “DMs0olHoap” is XP.
That’s odd that it needs to be a melee weapon. If you want this script to work with a ranged weapon I suppose you could create a script on the dummy unit with the ‘when this entity touches projectile’ trigger and make it give XP to the source unit of the triggering projectile. Glad you got it working, though.