Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Torso Follows Player, not working?

Asked by 4 years ago
Edited 4 years ago

okay so, basically everyone knows that script people use to make models of eyes follow a player position, right? I added the same script into an NPC's torso, now the first time it worked in studio, but then in-game, it just didn't function correctly, therefore the script didn't work. I checked the developer log to see the issue and it states "Line 5, attempt to index field 'Character' (a nil value)


while wait() do local players = game.Players:GetChildren() for i = 1, #players do if players[i].Character:FindFirstChild("Torso") ~= nil and (script.Parent.Position - players[i].Character.Torso.Position).magnitude <= 50 then script.Parent.CFrame = CFrame.new(script.Parent.Position, players[i].Character.Torso.Position) end end end

im depending on you guys to put together whats the issue, either way, I don't know what to do with my life.

Answer this question