You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
When my player kicks (or punches) another player or NPC I want an animation to play in that other player or NPC (animation causes them to slump over).
- What is the issue? Include screenshots / videos if possible!
It works great against other players in the game but not with any NPCs.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I am using the same code for both players and NPCs because they both have a Humanoid to apply the animation against. This did’t work so I added a line to make sure this slumping animation was the highest priority animation since often the NPC is engaged in an animation when I am kicking or punching them. This did not solve the problem
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Here is my code on the Server side
game.ReplicatedStorage.PunchEvent.OnServerEvent:Connect(function(player, victim, humanoid)
local animation = Instance.new("Animation")
animation.AnimationId = "https://www.roblox.com/Asset?ID="..8381045470
loadedAnimation = humanoid:LoadAnimation(animation)
loadedAnimation.Priority = Enum.AnimationPriority.Action
loadedAnimation:Play()
end)
Here is my code on the client side:
game.Players.LocalPlayer.Character:WaitForChild("RightHand").Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
PunchEvent:FireServer(hit.Parent, hit.Parent.Humanoid)
end
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.