Hello fellow developers, I’m making an ability where you hit someone and they get knocked back and play an animation. However, the animation just doesn’t play. Heres my script:
(“V” was found through magnitude" All the dummies parts are unanchored and everything but it just doesn’t play even when I tried it on another real player. Anyone know why?
You dont need to set an animation track to the humanoid as multiple scripts can play animations through the same animation instance ( I usually keep it in replicated storage )
Try setting the network ownership to nil. Maybe it cant play it because the plr has ownership?
A lot of it is probably irrelevant but here you go
for _,v in pairs(workspace.Entities:GetChildren()) do
if v ~= char and db == false then
if v:FindFirstChild("HumanoidRootPart") then
if (char.HumanoidRootPart.CFrame.p - v.HumanoidRootPart.CFrame.p).Magnitude <= 6 then
if v.Humanoid.Health > 0 and active == true then
enemyanim.Parent = v.Humanoid
local EnemyHit = v.Humanoid.Animator:LoadAnimation(enemyanim)
hit = true
active = false
Event_:Disconnect()
if Idleanim1 then Idleanim1:Stop() end
if Idleanim2 then Idleanim2:Stop() end
local hitload = hum.Animator:LoadAnimation(hitanim)
hitload:Play()
you can read about network ownership here but a quick bad summary is that if its ownership is nil the server handles its physics, animations, and other stuff but if its on a client then it handles it on that client, meaning the client can edit its position its animations and all that fun stuff.
Ownerships of unanchored parts are set to the nearest player and stuff
You cant set models ownerships they dont have ones, you have to set the BaseParts ones which I think you can just set its humanoidRootPart unless im wrong and you have to set all of them which u could do with a for i, v loop
The only thing I can think of thats causing it now is the animation track. Instead of setting the tracks parent to the humanoid try just loading it from replicatedStorage
local track = humanoid:WaitForChild("Animator"):LoadAnimation(replicatedStorage.Animations.Knocked)
remote.OnServerEvent:Connect(function(plr)
-- do ur stuff
if inrange then
track:Play()
end
end)