I made a slide animation for my game. to run it I put a script in StarterCharacterScripts (
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local Animate local Humanoid = player.Character:FindFirstChild('Humanoid') mouse.KeyDown:Connect(function(Key) if Key == "e" then print("e pressed") local Animation = Instance.new("Animation", player.Character) Animation.AnimationId = "rbxassetid://6383389820" Animate = Humanoid:LoadAnimation(Animation) Animate:Play() end end)
) in the debug menu it says "e pressed" so I don't think its a problem with the KeyDown function can anyone help?
I think your problem is that you cannot add a localplayer inside of a server script maybe try making it a localscript or use the PlayerAdded and characterAdded let me show you
game.Players.PlayerAdded:Connect(function(player) player.Character.CharacterAdded:Connect(function(character) local mouse = player:GetMouse() local humanoid = character:WaitForChild('Humanoid') local animate mouse.KeyDown:Connect(function(Key) if Key == 'e' then print('e pressed') local animation = Instance.new('Animation', character) animation.AnimationId = "rbxassetid://6383389820" animate = humanoid:LoadAnimation(animate) animate:Play() end end) end) end)
or maybe try a localscript but again this is confusing and i get your problem hope this somewhat helps