Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Client is only playing animation, can you help?

This is a local script in Starter Character Scripts

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local humanoid = localPlayer.Character:WaitForChild("Humanoid", 1)
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://6793653980"
animation.Parent = humanoid

loadedAnimation = humanoid.Animator:LoadAnimation(animation)

UserInputService.InputBegan:Connect(function(input, gameProccesed)
	if gameProccesed then
		return
	else
		if input.KeyCode == Enum.KeyCode.LeftShift then
			humanoid.WalkSpeed = 25

			loadedAnimation:Play()
		end
	end
end)

UserInputService.InputEnded:Connect(function(input, gameProccesed)
	if gameProccesed then
		return
	else
		if input.KeyCode == Enum.KeyCode.LeftShift then
			humanoid.WalkSpeed = 16
			loadedAnimation:Stop()
		end
	end
end)

I don't understand why this is happening, I have made it so the server runs it, same problem, I'm thinking it's because the walk animation is overwriting it. I tried fixing it, no luck. Need help!

(THIS IS NOT MY SCRIPT, I MUST SAY, I HAVE EDITED IT HOWEVER.)

Update: I found out that it is only happening on my side, I could see my alt running however it didn't show me running on the alt side. Fixes? Also, updated script.

Update2: Randomly fixed itself. If you can please close the thread/question

Many thanks, Narwhal

8 comments

0

You should be using Animator:LoadAnimation() as Humanoid:LoadAnimation() is deprecated. Also, what is the AnimationPriority of the animation?

0

Im pretty sure its core, and ill take that,

0

Changed it to movement if it'd help, didnt, also changed it to animator didnt work either.

0

try setting the networkOwnerShip? maybe that will work

0

i think your trying to make a run script

0

i dont get why you think the animation is only playing on the client because the client owns the character and anything that happens in the character happens automatically on the server

0

if you really cant get it playing then just use a remote event

0

this script is strange. instead of loading the animation only once, it makes a new animation every time you press shift. the way it should happen is that you only load it once and it is stored to be played later. if you are unsure how to implement ask and I will post later.

1 answer

either you play the game

press left shift

swap to the server side expecting the client to still run trying to see if animation is playing on the server

the character animation swapped to idle because input has ended and input has ended because you swapped to server side of things

thats the only way i could think of that you think the animation isnt playing and that would be a YOU problem

or if it is true that it isnt your problem then my only solution would be to set ownership maually or use a remote event in the code below

--local script
local UserInputService = game:GetService("UserInputService")

local Players = game:GetService("Players")

local localPlayer = Players.LocalPlayer
	 
UserInputService.InputBegan:Connect(function(input)
	--im telling you that you really only ever need input
	--you really dont need gameprocessedevent
	if input.KeyCode == Enum.KeyCode.LeftShift then
		
		humanoid = localPlayer.Character:WaitForChild("Humanoid")
		
		humanoid.WalkSpeed = 25
			
			
		
		local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvent
		
		RemoteEvent:FireServer()	
	end
	
end)
	 

UserInputService.InputEnded:Connect(function(input, gameProccesed)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		
		humanoid.WalkSpeed = 16
		
		loadedAnimation:Stop()	
	end
end)

server script

local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvent
RemoteEvent.OnServerEvent:Connect(function()
		local animation = Instance.new("Animation")
			
		
		animation.AnimationId = "rbxassetid://6793653980"
			
		
		animation.Parent = humanoid
				 
			
		
		loadedAnimation = humanoid:LoadAnimation(animation)
			
		
		loadedAnimation:Play()	

end)

3 comments

0

Hey, i used an alt and was sprinting on my main and looking on my alt, so no you are incorrect at the start. i did make a script like this also didnt work however.

0

Also, why is it stopping the animation in the client script instead of the server script?

0

i tried

This discussion is preserved as it was. New answers, comments, and votes are closed.