Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Sword swinging animation not playing in test server?

Asked by 5 years ago

[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!

0
game.Workspace[player.Name].Humanoid:LoadAnimation() Load the animation on the Humanoid. User#19524 175 — 5y
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 vroom4163 0 — 5y
0
Did you make sure the animation's priority is set to action? TiredMelon 405 — 5y
0
Yeah, the priority was set to action vroom4163 0 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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!

Answer this question