Use Code blocks and KeyDown is deprecated. Switch to InputBegan from UserInputService. I will add a RemoteEvent so the server can play the animation and other players can see it.
local player = game:GetService("Players").LocalPlayer
local rep = game:GetService"ReplicatedStorage"
local inputService = game:GetService"UserInputService"
inputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
rep.PlayAnimation:FireServer(game.Workspace.Anims.Animation)
end
end)
inputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
rep.StopAnimation:FireServer(game.Workspace.Anims.Animation)
end
end)
local rep = game:GetService"ReplicatedStorage"
rep.PlayAnimation.OnServerEvent:Connect(function(player, animation)
animTrack = game.Workspace[player.Name].Humanoid:LoadAnimation(animation)
animTrack:Play()
end)
rep.StopAnimation.OnServerEvent:Connect(function(player, animation)
animTrack:Stop()
end)
4 comments
oh no the code is kinda jumbled up...sry... :(
cant read soz
i would use userinputservice keydown is deprecated