I’ve made a walk animation for my tool but whenever I try to swap the current walk animation for the tools in the animate script it doesn’t work. any ideas as to what’s going wrong?
task.wait(.5)
local tool = script.Parent
local rps = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
repeat wait() until Player.Character
local character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = character:FindFirstChild("Humanoid")
local idleAnim = rps.Animations.Idles.BrawlIdle
local walkAnim = rps.Animations.Walks.Brawl.BrawlWalk1
local idletrack = Humanoid:LoadAnimation(idleAnim)
idletrack.Priority = 0
tool.Equipped:Connect(function()
game.Players.LocalPlayer.Character.Animate.walk.WalkAnim.AnimationId = "rbxassetid://15372964157"
Humanoid:ChangeState(Enum.HumanoidStateType.Landed)
idletrack:Play()
end)
tool.Unequipped:Connect(function()
game.Players.LocalPlayer.Character.Animate.walk.WalkAnim.AnimationId = "rbxassetid://11588923735"
Humanoid:ChangeState(Enum.HumanoidStateType.Landed)
idletrack:Stop()
end)
You will have to make a walk animation just how you did your idle animation. As far as I am awere of, changing the property won’t work, unless you do it before it’s loaded. This is because it just uses the properties once, at the beginning.
Sorry about first, I didn’t see(I really didn’t even after put second question about it’s priority💀), but why you won’t just change basic animation instead of playing it by script?
Also, use RunAnim instead of WalkAnim.
Like this:
the game I’m trying to make is going to just be pc as I’m not that well experienced in scripting so I’m not planning on adding any mobile or console support in a while or at all if I can actually finish it
I think you didn’t understand me. WalkAnim isn’t used on PC, use RunAnim instead.
Fixed code:
task.wait(.5)
local tool = script.Parent
local rps = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
repeat wait() until Player.Character
local character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = character:FindFirstChild("Humanoid")
local idleAnim = rps.Animations.Idles.BrawlIdle
local walkAnim = rps.Animations.Walks.Brawl.BrawlWalk1
local idletrack = Humanoid:LoadAnimation(idleAnim)
idletrack.Priority = 0
tool.Equipped:Connect(function()
game.Players.LocalPlayer.Character.Animate.run.RunAnim.AnimationId = "rbxassetid://15372964157"
Humanoid:ChangeState(Enum.HumanoidStateType.Landed)
idletrack:Play()
end)
tool.Unequipped:Connect(function()
game.Players.LocalPlayer.Character.Animate.run.RunAnim.AnimationId = "rbxassetid://11588923735"
Humanoid:ChangeState(Enum.HumanoidStateType.Landed)
idletrack:Stop()
end)
Unfortunately, the code still doesn’t work when I changed it to the Running animation but I’m currently trying to use the StateChanged event to play the animation
this is what I’ve got so far but when the player stops moving the animation doesn’t stop:
task.wait(.5)
local tool = script.Parent
local rps = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
repeat wait() until Player.Character
local character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = character:WaitForChild("Humanoid")
local idleAnim = rps.Animations.Idles.BrawlIdle
local walkAnim = rps.Animations.Walks.Brawl.BrawlWalk1
local idletrack = Humanoid:LoadAnimation(idleAnim)
local walkTrack = Humanoid:LoadAnimation(walkAnim)
idletrack.Priority = 0
tool.Equipped:Connect(function()
Humanoid.Running:Connect(function()
walkTrack:Play()
end)
Humanoid.StateChanged:Connect(function(old, new)
if new ~= Enum.HumanoidStateType.Running then
walkTrack:Stop()
end
end)
idletrack:Play()
end)
tool.Unequipped:Connect(function()
walkTrack:Stop()
idletrack:Stop()
end)
I figured it out using the Humanoid.Running function. Here is the script for anyone who may need it:
local Player = game.Players.LocalPlayer
task.wait(.5)
repeat wait() until Player.Character
--Variables
local tool = script.Parent
local rps = game:GetService("ReplicatedStorage")
local character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = character:WaitForChild("Humanoid")
local idleAnim = rps.Animations.Idles.BrawlIdle
local walkAnim = rps.Animations.Walks.Brawl.BrawlWalk1
local idletrack = Humanoid:LoadAnimation(idleAnim)
local walkTrack = Humanoid:LoadAnimation(walkAnim)
idletrack.Priority = 0
walkTrack.Priority = 1
local equipped = false
--Main Script
tool.Equipped:Connect(function() --tool idle
equipped = true
idletrack:Play()
end)
tool.Unequipped:Connect(function() --Stops animations
equipped = false
walkTrack:Stop()
idletrack:Stop()
end)
Humanoid.Running:Connect(function(speed) --walk animation
if equipped == true and speed > 0 then
walkTrack:Play()
end
if speed == 0 then
walkTrack:Stop()
end
end)