SCRIPT IN STARTERPLAYERSCRIPTS
local Player = game:GetService("Players").LocalPlayer
local PlayAnimation = game.ReplicatedStorage.PlayAnimation --It states that its "unable to cast value to object"
local StopAnimation = game.ReplicatedStorage.StopAnimation
local Debounce = false
function onKeyPress(actionName, userInputState, inputObject)
if userInputState == Enum.UserInputState.Begin then
PlayEmote()
end
end
function PlayEmote()
if Debounce == false then
PlayAnimation:FireServer(2471625994)
else
StopAnimation()
end
end
game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.E)
SCRIPT IN SERVERSCRIPTSERVICE
game.ReplicatedStorage.PlayAnimation.OnServerEvent:Connect(function(Player,Animation)
local Anim = game.Workspace[Player.Name].Humanoid:LoadAnimation(Animation)
Anim:Play()
game.ReplicatedStorage.StopAnimation.OnServerEvent:Connect(function(Player)
Anim:Stop()
end)
end)
HOW IT WORKS: Basically, it's supposed to load an animation when you press E on the keyboard.

6 comments
Why are you playing animations on the server. Remotes are quite latent as it takes time for stuff to be transferred from one side to the other. Playing animations from the client will replicate, as clients have network ownership of their humanoid. It's less work for the server.
also plz use the character property of player k thx
Use
localfunctions :)also don't get the local player in a script
assuming its a script cause you said "SCRIPT IN STARTERPLAYERSCRIPTS"
Which line is this bug occurring at? I'd rather not scour each line of code to find similarities between them to the error you've mentioned. Additionally, @theking, it's probably a bit pedantic to assume he means Script over LocalScript, I'm sure it's just something he didn't look to clarify.