Someone on the forum helped me make a script but when I tried to use it with different NPCs it doesn’t work. im not sure why
local function tweenNPCToFacePlayer(npc, player)
-- checks
if not npc or not npc.PrimaryPart then return end
local character = player.Character
if not character or not character:FindFirstChild("HumanoidRootPart") then return end
local npcRoot = npc.PrimaryPart
local targetPos = character.HumanoidRootPart.Position
-- new rotated CFrame for the NPC, but only on Y-axis
local currentPos = npcRoot.Position
local lookAtPos = Vector3.new(targetPos.X, currentPos.Y, targetPos.Z)
local goalCFrame = CFrame.new(currentPos, lookAtPos)
local tweenInfo = TweenInfo.new(
1, -- adjust this tween duration
Enum.EasingStyle.Quad, -- I thought it would be fancier than linear
Enum.EasingDirection.Out
)
local tween = TweenService:Create(npcRoot, tweenInfo, {CFrame = goalCFrame})
tween:Play()
end
local NPCfolder = game.Workspace.NPCs
-- List of specific NPCs to affect
local targetNPCNames = {"MrsWinslow", "Nicole"}
-- Loop through the NPCs and only affect the specified ones
for _, npc in ipairs(NPCfolder:GetChildren()) do
if table.find(targetNPCNames, npc.Name) then
tweenNPCToFacePlayer(npc, player) -- Call your function to make the NPC look at the player
print("LOOK plspspls look")
its supposed to make the npcs turn to look at u once
Events.TalkingToTeacher.OnServerEvent:Connect(function(player)
Events.TeleportEvent:FireAllClients()
happens
thx