Hello, I am having a problem with the AnimationTrack instance. It seems not to be playing when the humanoid is running. (By the way, I don't Use UserInputService.InputBegan because when the player holds 2 keys, the animation stops. I use Humanoid.StateChanged because this is accurate of the current humanoid status, meaning that it will be always correct. Used pcall to catch errors.) (I also called it "Animate" so it overrode the default animation script, on a local script)
Everything still is working fine, the pcall return, the StateChanged event, the RemoteEvent to the server.. (Also I just used the server to change the humanoid's WalkSpeed value and this allows it to be FE (Or is player WalkSpeed already FE? I also used the server for client sanity checks.)
Here is the client-sided code:
local players = game.Players local player = players.LocalPlayer local char = player.Character or player.CharacterAdded:Wait() local animwalk = script:WaitForChild("Animation") local humanoid = char:WaitForChild("Humanoid") local loadwalk = humanoid.Animator:LoadAnimation(animwalk) humanoid.StateChanged:Connect(function(old, new) if new == Enum.HumanoidStateType.Running then local succ, err = pcall(function() print("anim playing") loadwalk:Play() wait(5) game.ReplicatedStorage.OnWalkBoostSpeedRequest:FireServer(humanoid, speed) end) if succ then print("Success!") end if err then print("Something is wrong!") end else print("Not Running!") end if new == Enum.HumanoidStateType.Jumping then print("Player is jumping") loadwalk:Stop() end end)
Finally, the server-sided code:
game.ReplicatedStorage.OnWalkBoostSpeedRequest.OnServerEvent:Connect(function(player, humanoidPassed, speedPassed) local succ, err = pcall(function() if humanoidPassed.WalkSpeed == 16 then humanoidPassed.WalkSpeed = humanoidPassed.WalkSpeed + 4 else wait(4) if humanoidPassed.WalkSpeed == 16 then print("Changed back") else print("Changing players walkspeed back to default..") humanoidPassed.WalkSpeed = 16 end end end) if succ then print("Success!") elseif err then print("There seems to be a error, go check it out: "..err) end end)
I don't know why it isn't working. The whole scripts got saved, so its unexplainable for me how it stopped working. Thank you for reading this.