so im trying to make a nice combat system for my game but i am a fairly new to scripting,but to further elaborate in my question how would i go about making a player/npc who has been punched by another player play an animation showing that the hit has landed again im pretty new to scripting so my attempt at this is laughable but here it is :
local Player = game.Players.LocalPlayer local Character = Player.Character local c = Player.Character
if Player:TakeDamage(5) -- the amount of damage a single punch does then
local Track = Instance.new("Animation")
Track.AnimationId = "rbxassetid://4787043272"
local Anim = c.Humanoid:LoadAnimation(Track)
Anim:Play()
end
i put this in StarterPlayer scripts

6 comments
I'm thinking maybe a while loop might work.
if i would want to do this for An npc what would i do then? would i just put this script in the npc and change up a few variables?
Yes, because the LocalPlayer wouldn't work.
hmm this didn't work out and nothing is showing up in output for the npc
Try that. I edited it.
Depending on the objective, you can include the "break" or remove it.