#Idle Animation Help
1 messages · Page 1 of 1 (latest)
local IDLE_ANIMATION_ID = "rbxassetid://86208710541886"
local IDLE_DELAY = 1 -- seconds
local UserInputService = game:GetService("UserInputService")
local character = script.Parent
local humanoid = character:FindFirstChildOfClass("Humanoid")
local animator = humanoid and humanoid:FindFirstChildOfClass("Animator")
local idleTrack = nil
local lastInputTime = os.clock()
local isIdlePlaying = false
local movementKeys = {
[Enum.KeyCode.W] = true,
[Enum.KeyCode.A] = true,
[Enum.KeyCode.S] = true,
[Enum.KeyCode.D] = true,
[Enum.KeyCode.Up] = true,
[Enum.KeyCode.Down] = true,
[Enum.KeyCode.Left] = true,
[Enum.KeyCode.Right] = true,
}
local function createIdleTrack()
if animator then
if idleTrack then
idleTrack:Stop()
idleTrack:Destroy()
end
local idleAnim = Instance.new("Animation")
idleAnim.AnimationId = IDLE_ANIMATION_ID
idleTrack = animator:LoadAnimation(idleAnim)
idleTrack.Name = "Idle"
idleTrack.Looped = true
end
end
local function playIdle()
if idleTrack and not isIdlePlaying then -- idle Animation play
idleTrack:Play()
isIdlePlaying = true
end
end
local function stopIdle()
if idleTrack and isIdlePlaying then
idleTrack:Stop()
isIdlePlaying = false -- Stop idle animation
end
end
UserInputService.InputBegan:Connect(function(input, processed)
if movementKeys[input.KeyCode] then
lastInputTime = os.clock()
stopIdle()
end
end)
UserInputService.InputEnded:Connect(function(input, processed)
if movementKeys[input.KeyCode] then
lastInputTime = os.clock()
stopIdle()
end
end)
-- Movement input check
This is the code
Im using for reference
why are you using a really hard script just for an idle animation?
its too hardcore for one
local Players = game:GetService("Players")
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
for _, playingTracks in pairs(humanoid:GetPlayingAnimationTracks()) do
playingTracks:Stop(0)
end
local animateScript = character:WaitForChild("Animate")
animateScript.idle.Animation1.AnimationId = "rbxassetid://9912090652"
end
local function onPlayerAdded(player)
if player.Character then
onCharacterAdded(player.Character)
end
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)
since i dont know how to script very much
but have lot of roblox studio knowdledge
this is a animation script i found from toolbox