Hello. I have been trying to change walking animation speed based on their walkspeed. I have scrolled down to find solution but cant find any.
So any help would be appreciated!!
5 Likes
You should be able to use the Speed
property to change the speed of the animation. Heres an example of this:
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Animation = ... --Define and play the animation here
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
local ScaleFactor = Humanoid.WalkSpeed/16 --This is just an example, but its essentially going to get higher as your walkspeed goes higher, with the default walkspeed of 16 starting at the default animation speed of 1
Animation.Speed = ScaleFactor
end
end)
end)
This is a very barebones example but hopefully gives you a decent idea on where to start
The property .Speed
is read-only, meaning that your can’t change the property like this.
You’re would need to use :AdjustSpeed()
to change the speed.
I think your script would work if you just change the .Speed
part:
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Animation = ... --Define and play the animation here
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
local ScaleFactor = Humanoid.WalkSpeed/16 --This is just an example, but its essentially going to get higher as your walkspeed goes higher, with the default walkspeed of 16 starting at the default animation speed of 1
Animation:AdjustSpeed(ScaleFactor)
end
end)
end)
2 Likes