So I've been trying to script a simple punch animation that plays when you left click.

I'm using a local script, a server script and a remote event to run it.

Here's the Server Script:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player,animationID)
	local animation = Instance.new("Animation")
	animation.AnimationId = "http://www.roblox.come/Asset?ID="..animationID
	
	local loadedAnimation = game.Workspace[player.Name].Humanoid:LoadAnimation(animation)
	loadedAnimation:Play()
	print("Punched")
end)

And here's the Local Script:

game:GetService("UserInputService").InputBegan:Connect(function(input, engine_processed)
	if engine_processed then
		return
	end

	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		game.ReplicatedStorage.RemoteEvent:FireServer(7199296854)
		print("Yes")
	end
end)

My friend (The owner) joined and the punching animation worked for him and I could see it. I thought it was because he was the owner so I asked him to join on his other account and it still worked, but when I tried to punch it did not work.

8 comments

0
  1. animations should be played on client sides
0
  1. you should load an animation once, and play that over and over again instead of loading animations over and over again
0
  1. make sure the animation works for both r15 and r6 rigs. the animation in the code only supports r6.
0

TTChaos, i got some stuff to say to you

1
  1. animations can be played on the server just fine, second one i agree with completely 3. how do you know that animation only supports r6?
1

Does the console say anything? I have a crouch animation and when it doesn't load in the game doesn't show it playing.

0

It does not show anything in the console. No errors.

0

Im pretty sure i've figured it out. Theres something wrong with my account and its not playing animations. I tried on one of my other accounts and it worked perfectly fine.