WHAT DO YOU WANT TO ACHIEVE?
I want to make a mob that follows you to a certain range that gives you coins on death. Mob has to hold sword
ADDITIONAL
Make the mob swing the sword
1 Like
Please search the forum before posting
So, you need to get your NPC model first. Define it in your script like you have done already.
local NPC = script.Parent
local Humanoid = script.Parent:FindFirstChild(“Humanoid”)
local HRP = script.Parent:FindFirstChild(“HumanoidRootPart”)
Next you want to make a function which gets the player closest to the NPC.
local function GetClosestPlayer(range)
local List = {}
local Target = nil
for i, v in pairs(game.Players:GetPlayers()) do
local dist = v:DistanceFromCharacter(HRP.position)
…
Any time you damage a player, create a “creator” tag.
local tag = Instance.new("ObjectValue")
tag.Value = plrChar -- this can either be the shooters character or plr object (adjust accordingly if you use character)
tag.Name = "creator"
tag.Parent = humanoid -- this is the enemies humanoid, again can be parented to their character (adjust to it if you use character)
game:GetService("Debris"):AddItem(tag,.5) -- destroys tag after half a second
And then make a died function for everyone’s humanoi…
2022/12/13 Update: Can’t believe this thread is 3 years old, I have updated the majority content of this tutorial (including the code) and improved readability.
Hello everyone! I am Headstackk.
I have developed a Weapon Framework used in my game Weaponry . In this post, I will explain how to get started with animating tools, especially weapons on Roblox.
In most of the Roblox weapon frameworks (Excluding advanced shooter frameworks such as Phantom Forces), I observed that they usually only ada…
For the last one how would I make it so the mob swings
You can create a AnimationTrack
Object, which would hold the NPC’s Animation swinging its sword when a Target is near
could i just make it so if a playe ris near i do :PlayAnimation
1 Like
Pretty much, yes
--Define your animation & load it before you start the loop
local Animation = script:WaitForChild("SwingAnimation")
local LoadAnimation = script.Parent.Humanoid.Animator:LoadAnimation(Animation)
--After finding a valid target in the loop
if Target then
Animation:Play()
end
There’s an entire RPG framework with template enemies included. Have you seen this yet? Are you looking to make your own?
[RPGBIGTHUMB]
I’ve created an RPG kit that anyone can now use! In this post, I will be explaining what it can do and how to use it. My main reasons for making this kit are: provide new developers and people who don’t code a system to work with easily, speed up the process for making RPGs, and provide my take on the way an RPG kit should be made.
THIS KIT REQUIRES THE PLACE IN USE TO BE PUBLISHED AND HAVE API ACCESS IN ORDER TO FUNCTION DUE TO THE SAVE SYSTEM BEING A REQUIREMENT TO BE COUNTED …
I am trying to make a custom rpg
Woah Jack, thanks for giving me the various topics. I was also thinking of making a NPC Sword a long time ago but the NPC would kill the next targets instantly. Thanks
1 Like
DShadeyy
(DShadeyy)
June 21, 2021, 12:35am
#10
Can you send me the one in the text?