Sprinting Animation Problem

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to make my sprinting script work properly

  1. What is the issue? Include screenshots / videos if possible!

The sprinting script is working fine until I notice something while playing the game with my friends
The issue is that I can’t see others running animation, I can see only my running animation

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I didn’t try anything yet, the only thing I think about is to copy paste the script into a normal script not local script but I think that would not work because there’s a stamina gui script in it too and I’m not really a scripter so I do not know how to do this.

here is the code

local UIS = game:GetService('UserInputService')
local Frame1 = script.Parent:WaitForChild('Frame1'):WaitForChild('Frame2')
local player = game.Players.LocalPlayer
local NormalWalkSpeed = 16
local NewWalkSpeed = 25
local ii = 10
local running = false
repeat wait() until game.Players.LocalPlayer.Character
local character = player.Character
local RepStorage = game:GetService("ReplicatedStorage")

local Hum = character:WaitForChild("Humanoid")
local AnimationID = 'rbxassetid://7365943209'

local Animation = Instance.new("Animation")
Animation.AnimationId = AnimationID
local loadedAnim = Hum:LoadAnimation(Animation)


local Players = game:FindService("Players")


local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local CharacterType = Humanoid.RigType
local R6 = Enum.HumanoidRigType.R6


local function CreateParticleEmitter(Parent: Instance)
	local NewEmitter = Instance.new("ParticleEmitter")
	NewEmitter.Transparency = NumberSequence.new(0.7, 0.9)
	NewEmitter.Texture = "rbxassetid://301956793"	
	NewEmitter.SpreadAngle = Vector2.new(10, 10)
	NewEmitter.Size = NumberSequence.new(0.3, 1)
	NewEmitter.Lifetime = NumberRange.new(0.3)
	NewEmitter.EmissionDirection = "Back"
	NewEmitter.Enabled = false
	NewEmitter.Parent = Parent
	return NewEmitter
end


local function SetParticleEmitters()
	if  CharacterType == R6 then
		local RightLeg = Character["Right Leg"]
		local LeftLeg = Character["Left Leg"]
		local ParticleEmmiterRight = CreateParticleEmitter(RightLeg)
		local ParticleEmmiterLeft = CreateParticleEmitter(LeftLeg)
		return ParticleEmmiterLeft, ParticleEmmiterRight
	end
end


-- Create Particle Emitters --
local ParticleLeft, ParticleRight = SetParticleEmitters()

UIS.InputBegan:connect(function(key, gameProcessed)
	if key.KeyCode == Enum.KeyCode.LeftShift and gameProcessed == false then
		if Hum.FloorMaterial == Enum.Material.Air or Hum.MoveDirection.Magnitude <= 0 then
			return
		else
			character.Humanoid.WalkSpeed = NewWalkSpeed
			ParticleRight.Enabled = true
			ParticleLeft.Enabled = true
			running = true
			loadedAnim:Play()
			Hum:GetPropertyChangedSignal("Jump"):Connect(function()
				loadedAnim:Stop()
				running = false
				ParticleLeft.Enabled = false
				ParticleRight.Enabled = false
				wait(0.6)
				character.Humanoid.WalkSpeed = NormalWalkSpeed
			end)
			while ii > 0 and running do
				ii = ii - 0.05
				Frame1:TweenSize(UDim2.new(ii / 10*0.965, 0, 1*0.647, 0), 'Out', 'Quint', .1, true)			
				wait()
				if ii <= 0 then
					ParticleRight.Enabled = false
					ParticleLeft.Enabled = false
					loadedAnim:Stop()
					character.Humanoid.WalkSpeed = NormalWalkSpeed
				end
			end
		end
	end
end)

UIS.InputEnded:connect(function(key, gameProcessed)
	if key.KeyCode == Enum.KeyCode.LeftShift and gameProcessed == false then
		character.Humanoid.WalkSpeed = NormalWalkSpeed
		running = false
		loadedAnim:Stop()
		ParticleRight.Enabled = false
		ParticleLeft.Enabled = false
		while ii < 10 and not running do
			ii = ii + 0.1
			Frame1:TweenSize(UDim2.new(ii / 10*0.965, 0, 1*0.647, 0), 'Out', 'Quint', .1, true)			
			wait()
			if ii <= 0 then
				loadedAnim:Stop()
				ParticleRight.Enabled = false
				ParticleLeft.Enabled = false
				character.Humanoid.WalkSpeed = NormalWalkSpeed
			end
		end
	end
end)

sorry if the script is quite long because there’s like particles and stuff in there too, what should I do to fix it?

6 Likes

Add an animator to your humanoid as I had a similar problem. Read about it here:

1 Like

This is because animations won’t replicate to the server without one in your humanoid.

1 Like

Sorry, I don’t really get it. I’m just a beginner to scripting. I tried to do what you said but I think I did something wrong, Could you explain more about it? I would be very appreciated

If the game’s owner is a group then make sure that all animations are exported with the group set as owner. If you use animations that are not owned by the group, you will be able to see them in roblox studio but they won’t play ingame

The animation was made by me, The problem is that other players can’t see the animation they can only see their own animation

2 Likes

Following on from what I said about needing an animator try this:

local animator = Instance.new(“Animator”)
animator.Parent = script.Parent.Humanoid

put this in a Normal script in the startercharacter

ps:sorry if the formatting or spelling is incorrect I am currently on a mobile device.

Incase that doesn’t work test the game in studio and check the output for any red text as that will alert you where the error is

Still doesn’t work, there’s also no errors. I found an article about changing custom animation by roblox where I could add a script in server script service that change default animation. Maybe if I can search for player walk speed or magnitude from there and then make them play animation if they have the sprinting speed. So other players could see the animation too. Would that work?

1 Like

Is your custom animations saved to action priority meaning that it wont stop when moving? and is looped?

1 Like

Ohhh, I get it now. I didn’t care about animation priority that much because I thought it was gonna do nothing but I read about it and realised that I set my running animation too low. Thanks!

Yeah I made that mistake 2 years ago when I was new