Spawning and Animating an NPC Locally

What I want to Achieve:

I’m remastering one of my old games from 2012, Entrepreneur Tycoon. It’s a single player tycoon game in a multiplayer environment. Right now, part of this works! The character spawns in, and he walks to the point and when the player completes the task, he walks away and then is destroyed. I will post the code.

Problem is, the character doesn’t animate when cloned locally. Basically he’s just a T-Post with no animated moving

My Code:

UIS.InputBegan:Connect(function(input)
	local humRoot = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
	local Magnitude = (script.Parent.Position - humRoot.Position).magnitude
	if input.KeyCode == Enum.KeyCode.E and Magnitude <= 6 and canInteract and job.Value == config.Job.Value then
		gui.Enabled = false
		canInteract = false
		game.ReplicatedStorage.AddMoney:InvokeServer(config.Money.Value, config.PTS.Value)
		part:WaitForChild("StationCustomer").Humanoid:MoveTo(part.Point2.Position)
		wait(5)
		part:WaitForChild("StationCustomer"):Destroy()
		wait(config.WaitTime.Value)
		gui.Enabled = true
		canInteract = true
		cloneCustomer()
		part:WaitForChild("StationCustomer").Humanoid:MoveTo(part.Point1.Position)
	end
end)

If anymore information is needed, please let me know!

Where’s your code that animates the NPC?

It’s the Roblox Animation Script that is loaded into Characters. It works in the server, but doesn’t work locally.

If it’s a Script it wont work when it’s cloned locally, and if it’s a LocalScript then you have to parent the NPC (Or the LocalScript) into a place where LocalScripts work, like the player character.

2 Likes

I’ll give that a shot! Thanks for the tip!