Okay so I have an animation but it doesn’t play for some reason. The “print(“Animation Playing”)” works but the animation doesn’t plays. I published the game and tried joining the game and seeing if it was a studio bug but it doesn’t work either.
local RemoteEvent = game.ReplicatedStorage.BestLawyer
RemoteEvent.OnServerEvent:Connect(function(player, Key)
if Key == "Z" then
print("Animation Playing")
local Animation = game.ReplicatedStorage.DeskSlam
local AnimTrack = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(Animation)
AnimTrack:Play()
end
end)
local RemoteEvent = game.ReplicatedStorage.BestLawyer
RemoteEvent.OnServerEvent:Connect(function(player, Key)
print("Pressed key")
if Key == "Z" then
print("Animation Playing")
local Animation = game.ReplicatedStorage.DeskSlam
local AnimTrack = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(Animation)
AnimTrack:Play()
end
end)
Btw this is the local script that is firing the event.
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local debounce = false
local RemoteEvent = game.ReplicatedStorage.BestLawyer
UserInputService.InputBegan:Connect(function(input)
if debounce == false then
if input.KeyCode == Enum.KeyCode.Z then
debounce = true
RemoteEvent:FireServer("Z")
end
end
end)
maybe try :WaitForChild("DeskSlam")? Idk. I think you should put a print statement after the variables are defined in the serverScript another after the animation is supposed to play. Did you get any errors in the output?
Didn’t work and it printed the last print(). (No errors in output btw)
local RemoteEvent = game.ReplicatedStorage.BestLawyer
RemoteEvent.OnServerEvent:Connect(function(player, Key)
print("Pressed key")
if Key == "Z" then
print("Animation Playing")
local Animation = game.ReplicatedStorage:WaitForChild("DeskSlam")
local AnimTrack = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(Animation)
AnimTrack:Play()
print("I dont know what to put in here")
end
end)
Maybe you should take the animation out of replicatedstorage and move it into the script?
local RemoteEvent = game.ReplicatedStorage.BestLawyer
RemoteEvent.OnServerEvent:Connect(function(player)
if player then
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
print("Pressed key")
print("Animation Playing")
local AnimTrack = humanoid.Animator:LoadAnimation(script:WaitForChild("animation"))
AnimTrack:Play()
end
end)
I dont see any need for adding a “key” variable.
local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local debounce = false
local RemoteEvent = game.ReplicatedStorage.BestLawyer
UserInputService.InputBegan:Connect(function(input)
if debounce == false then
if input.KeyCode == Enum.KeyCode.Z then
debounce = true
RemoteEvent:FireServer()
end
end
end)