Animations not working

I have a knife animation in a tool, it plays on my screen in studio, but not on my friends screen in studio. I’m wondering how to fix this? here is the script:

local tool = script.Parent
local cooldown = script.cooldown.Value
cooldown = false
local Activated = false
tool.Activated:Connect(function()
	local humanoid = tool.Parent:FindFirstChildWhichIsA('Humanoid')
	local animation =script.swing
	if humanoid and cooldown == false then
		Activated = true
		cooldown = true
		local playanim = humanoid:LoadAnimation(animation)
		playanim:Play()
		wait(2)
		playanim:Stop()
		wait(2)
		cooldown = false
		Activated = false
	end
end)

script.Parent.Activated:Connect(function()


end)

script.Parent["knife part 2"].TouchEnded:Connect(function(BasePart)
	if BasePart.Parent.Parent.Name == "ZombieFolder" then
		if Activated then
			BasePart.Parent.Humanoid.Health -= script.Parent:GetAttribute("Damage")
		end
	end
end)
1 Like

Make the animation play when a remote event has beened called

Current script your using

local tool = script.Parent
local cooldown = script.cooldown.Value

cooldown = false
local Activated = false
tool.Activated:Connect(function()
	local humanoid = tool.Parent:FindFirstChildWhichIsA('Humanoid')
	local animation =script.swing
	if humanoid and cooldown == false then
		Activated = true
		cooldown = true
		
		remotiveEvent:FireServer()
		cooldown = false
		Activated = false
	end
end)

script.Parent.Activated:Connect(function()

Server script


remoteEvent.OnServerEvent:Connect(function(player)
local humanoid = player.Character.Humanoid
if humanoid:FindFirstChild("Animator") then
    if humanoid.Animator:FindFirstChild(ANIMTION) then
     animtion:Play()
else
local knifeAnim  = animator:LoadAnimation(ANIMATION)
knifeAnim:Play()
else
local animator = Instance.new("Animator")
animator.Parent = humanoid
local knifeAnim  = animator:LoadAnimation(ANIMATION)
knifeAnim:Play()


then


Ok, i’ll try this. thank you for your help

The animation has to be played in a server script, try this.

local tool script:

local tool = script.Parent
local cooldown = script.cooldown.Value
cooldown = false
local Activated = false
tool.Activated:Connect(function()
	local humanoid = tool.Parent:FindFirstChildWhichIsA('Humanoid')
	local animation =script.swing
	if humanoid and cooldown == false then
		Activated = true
		cooldown = true
		local playanim = humanoid:LoadAnimation(animation)
		RemoteEvent:FireServer(playanim, "Start") -- put your remote event here
		wait(2)
		RemoteEvent:FireServer(playanim, "End") -- put your remote event here (same remote event)
		wait(2)
		cooldown = false
		Activated = false
	end
end)

script.Parent.Activated:Connect(function()


end)

script.Parent["knife part 2"].TouchEnded:Connect(function(BasePart)
	if BasePart.Parent.Parent.Name == "ZombieFolder" then
		if Activated then
			BasePart.Parent.Humanoid.Health -= script.Parent:GetAttribute("Damage")
		end
	end
end)

server script:

RemoteEvent.OnServerEvent:Connect(function(Player, Anim, Status)
if Status == "Start" then
Anim:Play()
end

if Status == "End" then
Anim:Stop()
end

end)

pretty sure this should work!

Character animations should be played on the client, the issue likely stems from animation ownership (an animation must be uploaded by a user/group in order for that animation to be played in that user’s/group’s games).

If I use a remote event to trigger the local script, where should I locate the local script?

Shouldn’t animations replicate to the server automatically?

They can, but I heard exploiters could mess them up if they’re done on the client
I use a remotevent to play the animation from the server

Exploiters can still set off remote events. The code mentioned above doesn’t use server side checking so exploiters can still do the same thing. If server side checking is used, it is fine I guess.

1 Like

Should I put the damage on client or server?

He could use some sanity checks on the server, so even if they try to mess up the remotes, as long as he has srong sanity checks, it would be fine

Yeah, else it would be pointless so hopefully he does.

Put it on the server. (Use server side checking with your remotes)

My knife script is on client, my damage and animation scripts are on server, but the animation still plays for me, but not my friends. I have no errors in the output. Does anybody know why this might be happening?

Is uploading the same thing as publishing? or do i have to do some thing else. @Forummer

i already published my animations.

I have done that, any other ideas why it might not be working?

How would I share the animation?
Here is the link

Link

could i just give you the id?

nvm WalkAnim - Roblox

oops, this is the wrong animation
here is the correct one… Untinimation Clip - Roblox