This script is not working correctly and it makes completly no sense for me

I was testing stuff and tried to make an eye that keeps looking at me but stay in the same position always, so I used a BodyPosition to keep the eye in place, I set It’s P to a very high number so I’m sure the ball will always stay in the same place.

Since I want it to follow the LocalPlayer I made a localscript inside StarterCharacterScripts for making the ball look at my character, in that script I make a BodyGyro with a CFrame so It’s looking at my character. (I’m doing this because I want a nicer and smoothy movement of the eye)

local Player = game.Players.LocalPlayer
local Character = script.Parent
local Root = Character:FindFirstChild("HumanoidRootPart")
local mouse = Player:GetMouse()
local RunService = game:GetService("RunService")
local EyeLook = game.Workspace:WaitForChild("EyeLook")

RunService.Heartbeat:Connect(function()
	PlayerLookAt() -- For making my character move where my mouse is

	EyeLookAt(EyeLook) -- For making the eye look at my character
end)

function EyeLookAt(part)
	
	if not part:FindFirstChild("BodyGyro") then -- If part has no BodyGyro create it.
		local BodyGyroII = Instance.new("BodyGyro")
		BodyGyroII.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
		BodyGyroII.P = 7000
		BodyGyroII.CFrame =  CFrame.lookAt(part.Position,Character.HumanoidRootPart.Position)

		BodyGyroII.Parent = part
	else
		local BodyGyroII = part:FindFirstChild("BodyGyro") -- If part already has it then update it.
		BodyGyroII.CFrame =  CFrame.lookAt(part.Position,Character.HumanoidRootPart.Position)
	end

end

The issue is:

When I join the game I have to get VERY close to the eye for it to look at me, as if there was a range/distance that I have to be in order for it to look at me, but the longer I stay in the game the more that range increases.

When the game starts It’s range is very low, but if I stay on it for long enough then It’ll be able to follow me for the entire map. This honestly makes no sense for me, all the script I’ve used is the one I’ve provided. PlayerLookAt() Works completly fine.

https://medal.tv/clips/47071457/d1337sPrI80O

Have you tried setting BodyGyroII.CFrame to this:

BodyGyroII.CFrame = CFrame.new(part.Position, Character.HumanoidRootPart.Position)

instead of using CFrame.lookAt() in both parts of the if statement? Seems like creating a new CFrame like that is preferable to using lookAt() as per the wiki.

1 Like

Hello, I’ve now tried this and it didn’t change anything, the same bug is happening.

I was able to recreate the problem and I see what the issue is. The problem is that the player is not the network owner when they first near the eye. If you aren’t sure what network ownership is, you can read about it here.

Here’s the specific part of the BodyGyro wiki article that talks about the problem you are having:

Any assembly containing a part that contains a BodyGyro or BodyPosition will not be simulated when interacting with a player unless that player is the network owner of the assembly.

This means that the eye will have to manually have its network ownership changed to the LocalPlayer. I made a sample place so that you can see how I went about solving it:

NetworkGyro.rbxl (23.5 KB)

1 Like

Nice! Setting the network ownership actually fixed that glitch!

I’ll be definetly taking a deeper look at network ownership, thanks for helping me out! I really appreciate it. :slight_smile:

1 Like