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

How can I make NPCs use weapons they're equipped with?

Asked by 4 years ago

I'm not even beginner level at roblox scripting, so I have no idea how this is supposed to work but I want an NPC to actually use the weapon it holds in its hand.

When a player is using the weapon, they can press left click to slash, double left click to lunge and press q to use a special ability... but NPCs don't have keys to press so it just holds the weapon as it walks up to me.

The weapon by the way is "Dagger Of Shattered Dimensions" - a gear by Roblox which I added to the NPC.

Just to be clear, I don't want some super-advanced AI that makes the NPC act just like a player, I just want the NPC to use the weapon... sort of like it's spamming left click or something. And then, I want it to use the special ability when it's under half health and is near the player.

I'm aware that I could try and just load the toolslash animation and pretend that the NPC is slashing that way, but what about the special? - Because that's more than just an animation.

Usually the idea of an NPC using a tool is pretty-down pat with any game, but when I tried to look up information on NPCs using weapons on roblox (properly) I get nothing.

I don't want my NPC to just have the tool equipped, I want it to use the weapon. Is there any way of achieving this?

0
Rn the function in the weapon you want to hiimgoodpack 2009 — 4y
0
well hm i say u should make a function in the weapon to auto swing and give the npc a animation as npcs are always characters so u cant use getmouse or input,KeyCode on them so i say like try a PlayerDistanceFromCharacter maybe and when the npc close enough the weapon will know that and start triggering the attack and u can make a repeat to constantly check the health like repeat until TNTIsLyfe 152 — 4y
0
i cant answer your question but i can try explain some things for example u have to try to edit the weapon script to find out something like u know how npcs run towards you u should try get the player.name of the player getting runned by a npc and then put that in ur weapon so the weapon knows who to hit or if u want something simple just put a simple animation and damage script in the weapon and TNTIsLyfe 152 — 4y
0
and use while true do so the weapon constantly registers the animation and the weapon dealing damage every animation u can also make a weapon hit cooldown if want and i hope these comments help u because i have no idea how to paste an answer anyway sorry TNTIsLyfe 152 — 4y
View all comments (2 more)
0
Thanks for these replies, guys! I will try some of these things. User#32134 0 — 4y
0
Unfortunately, I don't think this will help me. I believe you guys have the right idea... but I tried and it didn't work. I don't think I have the scripting skills it would take to get it to work. User#32134 0 — 4y

Answer this question