Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Sword swinging animation not playing in test server?

[New to scripting btw]

I'm not understanding why my animation for swinging the sword isn't playing in the test server. Heres the LocalScript followed by the server Script:

LocalScript

local player = script.Parent.Parent
local tool = script.Parent
local swingevent = game.ReplicatedStorage.swingevent


tool.Equipped:connect(function(Mouse)

Mouse.Button1Down:connect(function()

print("Slash")  

swingevent:FireServer()	     
    end)
	
end)

Script

local swingevent = game.ReplicatedStorage.swingevent
local tool = script.Parent
local character = tool.Parent

swingevent.OnServerEvent:connect(function(player)
	print(player.Name.." swung the sword!")
	local animation = Instance.new("Animation")
	animation.AnimationId = "http://www.roblox.com/asset/?id=2035212005"
	
	local loadAnim = game.Workspace[player.Name].Humanoid.Animator:LoadAnimation(animation)
	loadAnim:Play()
	
end)

The RemoteEvent fires, but only prints (player.Name.." swung the sword!"), not loading the animation. I want other clients to see this animation performed. Thanks in advance!

4 comments

0

game.Workspace[player.Name].Humanoid:LoadAnimation() Load the animation on the Humanoid.

0

Changed it to load on the humanoid. Animation plays in studio, but when I load up a local server, the server doesn't see the animation

0

Did you make sure the animation's priority is set to action?

0

Yeah, the priority was set to action

2 answers

Local Script

local player = game.Players.LocalPlayer
local tool = script.Parent
local swingevent = game.ReplicatedStorage.swingevent
	 
	 
tool.Equipped:connect(function(Mouse)	 
	Mouse.Button1Down:connect(function()
		 
		print("Slash") 
		swingevent:FireServer()     
	 end)
end)

Script

local swingevent = game.ReplicatedStorage.swingevent
local tool = script.Parent
local character = tool.Parent
	 
swingevent.OnServerEvent:connect(function(player)
    local Char = player.Character
    print(player.Name.." swung the sword!")
    local animation = Instance.new("Animation")
    animation.AnimationId = "http://www.roblox.com/asset/?id=2035212005"
 
    local loadAnim = Char.Humanoid.Animator:LoadAnimation(animation)
    loadAnim:Play()
 
end)

You probably created the animation in R15 and tested it out in R6, or vice versa. A solution could be to simply publish the game, and change the game settings so it converts to R15 or R6, depending on what rig type you animated on. Or you could create an R6 animation to accompany your R15 animation, and convert depending on players' rig types.

It is likely that it has nothing to do with your code. It looks absolutely fine. I have the same problem, and I fixed it with the solution above.

Hope this helped!

This discussion is preserved as it was. New answers, comments, and votes are closed.