Hello!
I made a script where it’ll get a model, get a random part, and make the NPC move to it. The problem is, it’s not working, I tried switching it to Position, and not with it, but I get errors for both:
Workspace.Reindeer.Logic:18: attempt to index number with ‘Position’
and:
Unable to cast number with ‘Vector3’
I know what the problem is, but I don’t know how to solve it. Any help is appreciated!
local npc = script.Parent
local humanoid = npc.Humanoid
local animator = humanoid.Animator
local animation = Instance.new("Animation")
local MoveTos = workspace.MoveTos:GetChildren()
local hrp = npc:WaitForChild("HumanoidRootPart")
animation.Parent = animator
animation.AnimationId = "rbxassetid://6085175514"
local RunService = game:GetService("RunService")
local animationplay = animator:LoadAnimation(animation)
animationplay.Looped = true
while true do
local randompart = math.random(1, #MoveTos)
wait(1)
humanoid:MoveTo(randompart.Position)
end
humanoid.Running:Connect(function(speed)
if speed > 0 then
animationplay:Play()
else
animationplay:Stop()
end
end)