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