Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make NPC's use abilities?

Asked by 5 years ago

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

0
you can use magnitude to see how close two characters are from each other (NPC.Torso.Position - YourCharacter.Torso.Position).Magnitude royaltoe 5144 — 5y
0
If the two characters are close in distance have the npc attack the character royaltoe 5144 — 5y
0
You can then let the npc use the attack on the character if the character is close enough to the character. royaltoe 5144 — 5y
0
Thanks! Also, would that be local script or script? hihowareya115 53 — 5y
View all comments (2 more)
0
Also, if you don't mind, i'm still new to scripting (2-3 months of experience), could you go into detail? hihowareya115 53 — 5y
0
Sure, do you want to talk on discord? Lucy#0003 royaltoe 5144 — 5y

2 answers

Log in to vote
0
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago

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.

01local effects = game.ReplicatedStorage.Effects
02local NPC = script.Parent
03 
04function 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.Part0 = fireBall
13    weld.Part1 = NPC.RightArm
14    wait(0.1)
15    weld:Destroy()
View all 60 lines...
Ad
Log in to vote
0
Answered by 4 years ago

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

Answer this question