this my script and its not working...
local plr = game.Players.LocalPlayer local mouse = plr:GetMouse()
mouse.KeyDown:Connect(function(Key) if Key == "e" then local animation = Instance.new("Animation",plr.character) animation.animationid = "rbxassetid://1580824405" animate = plr.Character:FindFirstChild('Humanoid'):LoadAnimation(animation) animate:play() end end)
mouse.KeyUp:Connect(function(Key) if Key == "e" then animate:stop() end end)
-Tizzel40
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.
--LocalScript 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) -- I put the animation in the Workspace in a Folder end end) inputService.InputEnded:Connect(function(input) if input.KeyCode == Enum.KeyCode.E then rep.StopAnimation:FireServer(game.Workspace.Anims.Animation) -- I put the animation in the Workspace in a Folder end end)
--ServerScript, handle animation playing/stopping. 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() -- It was declared global so no errors here end)