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

Can someone add animations on hit in this script ? [closed]

Asked by 8 years ago

I would GREATLY appreciate it if someone could try and add it so in this script, when the NPC hits an attack animation plays.

If this isn't possible tell me please.

r = game:service("RunService") 
ching = false 


local mobs = script.Parent.Mobs:GetChildren()
for i = 1, #mobs do
function blow(hit) 
if ching == true then return end 
local humanoid = hit.Parent:FindFirstChild("Humanoid") 
if humanoid~=nil then 
local vCharacter = humanoid.Parent 
local vPlayer = game.Players:playerFromCharacter(vCharacter) 
cl = script.TextRiser:Clone()
cl2 = script.FadeClean:Clone()
ching = true 
print("SWORD HIT") 
tagHumanoid(humanoid, vPlayer) 
local damage = math.random(mobs[i].SETTINGS.MinDmg.Value,mobs[i].SETTINGS.MaxDmg.Value) 
humanoid:TakeDamage(damage) 
local part = Instance.new("ScreenGui") 
local part2 = Instance.new("TextLabel") 
part2.FontSize = "Size24"
part2.Font = "ArialBold"
part2.Size = UDim2.new(0,50,0,50) 
part2.Position = UDim2.new(0.5,0,0.35,0) 
part2.BackgroundTransparency = 1
part2.Parent = part 
cl.Parent = part2
cl.Disabled = false
cl2.Parent = part2
cl2.Disabled = false
part.Parent = vPlayer.PlayerGui 
if (damage == 0) then 
part2.TextColor3 = Color3.new(0/255,102/255,255/255) 
part2.Text = ""..damage.."" 
else 
part2.TextColor3 = Color3.new(255/255,0/255,0/255) 
part2.Text = "-"..damage.."" 
end 
wait(1) 
ching = false  
wait(.1) 
untagHumanoid(humanoid) 
else print("Humanoid does not exist or incorrect humanoid!") --Attempt to make sword unbreakable.
end 
end 

function tagHumanoid(humanoid, player) 
local creator_tag = Instance.new("ObjectValue") 
creator_tag.Value = player 
creator_tag.Name = "creator" 
creator_tag.Parent = humanoid 
end 

function untagHumanoid(humanoid) 
if humanoid ~= nil then 
local tag = humanoid:FindFirstChild("creator") 
if tag ~= nil then 
tag.Parent = nil 
end 
end 
end 
mobs[i].Sword.Handle.Touched:connect(blow)
end

Closed as Not Constructive by BlackJPI and User#6546

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?