My NPC look to sound script isn't working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want to make an NPC that looks at sounds

  1. What is the issue? Include screenshots / videos if possible!

It keeps giving this error

FireSound inside of Handle
Sound found
[16:15:14.853 - Position is not a valid member of Model]
16:15:14.853 - Stack Begin

[16:15:14.854 - Script 'Workspace.Dummy.Script', Line 10

16:15:14.854 - Stack End 
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I didn’t look anywhere.
local p1 = script.Parent

game:GetService("RunService").Stepped:Connect(function()
	for i, v in pairs(game.Workspace:GetDescendants()) do
		if v:IsA("Sound") and v.Playing == true and not v.Parent:IsA("Model") and v.Parent:IsA("BasePart") then
			repeat wait() until v ~= nil and v.Parent ~= nil
			print(v.Name .." inside of ".. v.Parent.Name)
			print("Sound found")
			local p2 = v.Parent
			p1.CFrame = CFrame.new(p1.Position, p2.Position)
			if v.Name == "FireSound" then
				print("Scared")
			end
		end
	end
end)
1 Like

Is p1 a Model? Not p2, but p1.

Thank you, it is. I forgot HumanoidRootPart.