Need help with a pet script

The script I made doesnt seem to be working, its about a mesh following you and facing you
It doesnt seem to be working and I get the error.

Workspace.NewPet.Script:12: Expected ‘)’ (to close ‘(’ at column 18), got ‘NewPet’

Here is the code its a script inside the Mesh

local NewPet = script.Parent NewPet.CanCollide = false
local PetPos = Instance.new("BodyPosition", NewPet)
local PetGyro = Instance.new("BodyGyro", NewPet)
PetGyro.MaxTorque = Vector3.new(400000,400000,400000)

local Owner = 'Kamcool435'

while(1) do
	task.wait()
	local OwnerObj = workspace:WaitForChild(Owner)
	local OwnerPos = OwnerObj.HumanoidRootPart.Position
	local StopAt = ((OwnerPos NewPet.Position) magnitude 5) * 1000
	PetPos.P = StopAt
	PetPos.Position = OwnerPos + Vector3.new(0,0,10)
	PetGyro.CFrame = OwnerObj.HumanoidRootPart.CFrame
end

Does anyone know how can I fix this?

2 Likes
OwnerPos - NewPet.Position

You forgot a symbol!!

1 Like
 local StopAt = ((OwnerPos - NewPet.Position).Magnitude - 5) * 1000

Try this line.

2 Likes

:flushed: whoopsies, i also did something wrong

1 Like

Thanks a lot I’m still learning Lua so I make lots of mistakes in coding

1 Like

Just so you know, I would go by the userid instead of the username because of usernames being able to be changed

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.