Playing an animation with a local script

I’m trying to play an animation client-sided so that only the player can see it but the animation won’t run, no errors.

local Player = game.Players.LocalPlayer
local char = Player.Character or Player.CharacterAdded:Wait()
local uis = game:GetService("UserInputService")


uis.InputBegan:Connect(function(input, gpe)
	if input.KeyCode == Enum.KeyCode.E and not gpe then
		local humanoid = char:WaitForChild("Humanoid")
		local animator = humanoid:FindFirstChildOfClass("Animator")
		local anim = Instance.new("Animation")
		anim.AnimationId = "rbxassetid://8800366627"

		local track = animator:LoadAnimation(anim)
		track.Looped = true
                track:Play()

	end
end)
1 Like

If the animation is loaded onto a humanoid, other players will still see it, even on a local script.
And I would recommend loading and making the animations before the input began, so you just need to do track:Play() in the function

3 Likes

For some reasons, it worked for me

Nevermind I found the issue, it wasn’t related to this script at all. I appretiate the help though

Im decently sure if you loaded a animation onto a humanoid other people can see it too, I think you should check if you want

If the animation object is instanced locally the animation will only replicate locally, you are correct though, if the animation is instanced by the server but then the animation track is played locally the animation will still replicate to the server.