I'm working on an open-world game where players can go around and kill NPCs. I know how to make regular NPC's that can attack and follow, but I don't know how to make ones that can use abilities. If it helps, here are is an example of what I mean along with the script and the ability I want the NPC to use.
Example (Source: Boku No Roblox): https://gyazo.com/d48f069d1305394bff66a70f7c81cff8
The ability I want the NPC to use (keep in mind that I'm not good at making particles): https://gyazo.com/b65e08d3eb7100bf27efaf02ed05dd7d
Script: https://pastebin.com/00Z9jRvn
We worked it out on discord. Here's the code if anyone wants to try it out for themselves: I tried to add comments to explain, but comment if you have any more questions.
01 | local effects = game.ReplicatedStorage.Effects |
02 | local NPC = script.Parent |
03 |
04 | function useFireball(playerToAttack) |
05 | --create the fireball |
06 | local fireBall = effects.MagicSkill:Clone() |
07 | fireBall.Position = NPC [ "Right Arm" ] .Position |
08 | fireBall.Parent = workspace |
09 |
10 | --weld the fireball to the npc's hand and destroy it after .1 seconds to give the effect that it came from the npc's hand. |
11 | local weld = Instance.new( "WeldConstraint" , fireBall) |
12 | weld.Part 0 = fireBall |
13 | weld.Part 1 = NPC.RightArm |
14 | wait( 0.1 ) |
15 | weld:Destroy() |
for some reason its not working for me please answer. I got a random npc put a script in him and copy and pasted what u said and i read the script and understoof that i need to make a folder called effects and put a fire ball inside and explosion i did that and still not working please help or anser please