RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"If a player holds the E key down, it will play an animation of my choice until they let go."
-- local script local Players = game:GetService("Players") local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local animation = Instance.new("Animation") animation.AnimationId = "rbxassetid://YOUR_ANIMATION_ID_HERE" -- Replace with your animation ID local animationTrack = humanoid:LoadAnimation(animation) local function onKeyDown(key) if key == Enum.KeyCode.E then animationTrack:Play() end end local function onKeyUp(key) if key == Enum.KeyCode.E then animationTrack:Stop() end end player:GetMouse().KeyDown:Connect(onKeyDown) player:GetMouse().KeyUp:Connect(onKeyUp)