Why does running animation play in studio, but not in game?

Well, the title says it all.

Here is the video of running inside studio:

And here is the “running” in the game:

And here is the code:

local player = game:GetService("Players").LocalPlayer
local UIS = game:GetService("UserInputService")
local char = script.Parent or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local RS = game:GetService("ReplicatedStorage")

local camera = workspace.CurrentCamera

local run = false

local animation = script:WaitForChild("Animation")
local loadedAnim = hum:LoadAnimation(animation)

local blocking = char:WaitForChild("Blocking")

local stamRemote = RS:WaitForChild("Remotes"):WaitForChild("Stamina")

UIS.InputBegan:Connect(function(input, gpe)
	
	if input.KeyCode == Enum.KeyCode.LeftShift and blocking.Value == false then
		
		hum.WalkSpeed = 20
		run = true
		
		stamRemote:FireServer("startedRun")
		
		if hum.MoveDirection.Magnitude > 0 and run == true and char:WaitForChild("Stamina").Value > 1  then
			
			camera.FieldOfView = 75
			
		end	
		
		while run == true and char:WaitForChild("Stamina").Value > 1 do
			
			run = true
			wait()
			
		end
		
		hum.WalkSpeed = 10
		loadedAnim:Stop()
		run = false
		
		if run == false then
			
			hum.WalkSpeed = 10
			
		end
			
	end	
	
end)

UIS.InputEnded:Connect(function(input, gpe)

	if input.KeyCode == Enum.KeyCode.LeftShift and blocking.value == false then
		
		run = false
		
		stamRemote:FireServer("stoppedRun")
		
		hum.WalkSpeed = 10
		camera.FieldOfView = 70

	end	

end)

hum.Changed:Connect(function()
	
	if hum.MoveDirection.Magnitude > 0 and run == true and char:WaitForChild("Stamina").Value > 1 then
		
		camera.FieldOfView = 75
		
	end
	
end)

camera:GetPropertyChangedSignal("FieldOfView"):Connect(function()
	
	if camera.FieldOfView == 75 then
		
		loadedAnim:Play()
		
	elseif camera.FieldOfView == 70 then
		
		loadedAnim:Stop()
		
	end
	
end)

It is indeed my animation, and I published it.

1 Like

I don’t see a reason why it wouldn’t work on Roblox if it works on Studio. The only possible reasons are;

  • The animation isn’t published (but you stated that you published it)
  • You do not have permission to use the animation (maybe if it is under a group game while the animation is under your account, or vice versa)
  • Instead of running the animation, you are running the object that you use to animate (so a saved instance of the animation, not the published one)
  • Roblox failed to load it (most likely reason)

Try to see if there are any errors in the Developer Console in-game (both on the client and the server).

5 Likes

The game is made by me, the animation is published. And I’m running an animation with the animation id set to the published animation. And I don’t know why roblox is failing to load it, I’ve tried over a dozen of times, and same result.

image

This is how the hierachy looks in the explorer

1 Like

I just tried to print on every line, the issue were on the FieldOfView:GetPropertyChangedSignal()

I fixed it. Thx anyway

2 Likes

how fix it? thanks lol xd 30 of these chafr cause its like character

My brain just died 7 times reading that. I can’t remember what I did but you can probably use camera.Changed()

Check if the animation was made by the group or user that the game is made by, otherwise the animations play in studio but don’t play in game.

It had nothing to do with the status of the animation. I think everybody knows how to properly publish animations at this point, also you don’t need to give the same answers as people already has in this thread.

The problem were my garbage code. Instead of calling GetPropertyChangedSignal() on the camera, I called it on the value I was trying to listen after instead, which obviously won’t work.

1 Like

Is it the cam Prop change that made the animation stop in game? Like why make the anim run when the FOV change instead of making it below the line that change the FOV amount?

Oh sorry for that, don’t forget to put your own message as a solution to close this thread.