My script makes a character walk across the screen when you join the game, but it only works in the studio but not on the actual Roblox game. Any help?
local char = script.Parent --the npc
local hum = char:WaitForChild("Humanoid") --the npc's humanoid
local animation = hum:LoadAnimation(script.Animation) --finds the animation inside the script and loads it in the npc's humanoid
if char ~= nil then --this just checks if the npc exists
animation:Play() --plays the animation
end

2 comments
Are you using a local script?
since its an npc you should load the animation into an AnimationController instead of a humanoid https://developer.roblox.com/api-reference/class/AnimationController