Hi you all. I’m trying to detect when a player’s WalkSpeed changes value. For some reason, when the character’s WalkSpeed changes, nothing happens, even the print statement doesn’t print anything. I tried detecting the WalkSpeed value change different ways but it won’t work. Maybe it’s just something simple I’m missing.
Here’s the script (ServerScript):
local Players = game:GetService("Players")
local runAnimation = Instance.new("Animation")
runAnimation.AnimationId = "rbxassetid://16754777947"
Players.PlayerAdded:Connect(function(plr)
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
print(humanoid.WalkSpeed)
if humanoid.WalkSpeed > 25 then
--Run Animation
local runAnimationTrack = humanoid:LoadAnimation(runAnimation)
if not runAnimationTrack.IsPlaying then
runAnimationTrack:Play(0.1)
end
end
end)
end)
cause Roblox call walking running idk. Just connect it then walk around and print the output.
change your walk speed and when you walk it will show the change…
ps: this doesn’t show when you change it will only show when you walk.
The code works now, and the animation plays, but the animation doesn’t flow back to the walking or idle animations smoothly.
Here is the code, It is stored in ServerScriptService under a folder called AnimationManagement:
--Services
local Players = game:GetService("Players")
--Variables
local runAnimation = Instance.new("Animation")
runAnimation.AnimationId = "rbxassetid://16754777947"
Players.PlayerAdded:Connect(function(plr)
--Variables
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local runAnimationTrack
humanoid.Running:Connect(function(speed: number)
print(speed)
if speed > 25 then
--Run Animation
runAnimationTrack = humanoid:LoadAnimation(runAnimation)
if not runAnimationTrack.IsPlaying then
runAnimationTrack:Play(0.1)
end
elseif speed == 0 then
--Stop Animation
runAnimationTrack:Stop()
end
end)
end)
local Players = game:GetService("Players")
local runAnimation = Instance.new("Animation")
runAnimation.AnimationId = "rbxassetid://16754777947"
Players.PlayerAdded:Connect(function(plr)
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = plr.Character:WaitForChild("HumanoidRootPart")
humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
print(rootPart.Velocity.Magnitude)
if rootPart.Velocity.Magnitude > 25 then
--Run Animation
local runAnimationTrack = humanoid:LoadAnimation(runAnimation)
if not runAnimationTrack.IsPlaying then
runAnimationTrack:Play(0.1)
end
end
end)
end)
The only problem is that the run animation gets played constantly over and over again and basically only plays a fraction of it.
The output says this:
AnimationTrack limit of 256 tracks for one Animator exceeded, new animations will not be played.
Might be because the magnitude of the velocity is also constantly changing by the decimal, from advanced calculating. Not really sure how to fix the animation problem