I am trying to make pet( the pet is model with primarypart) but, I need to make it rotate where you look. I don't know how and I am asking for help.
Code :
local Pet = script.Parent local Move = script.Parent:WaitForChild('Move') Move.OnServerEvent:connect(function(Player) if workspace[Player.Name] then local Head = workspace[Player.Name]:FindFirstChild('Head') if Head then Pet:SetPrimaryPartCFrame(CFrame.new(Head.CFrame.X + 1,Head.CFrame.Y + 2,Head.CFrame.Z + 1)) Pet:SetPrimaryPartCFrame(Pet.Hitbox.CFrame * CFrame.Angles(0,Head.CFrame.lookVector.Z,0)) end end end)
Please help!
Hi Sou,
local part_to_lookat = head.Position; local pos_to_stay = primpart.CFrame.p; primpart.CFrame = CFrame.new(pos_to_stay, pos_to_lookat);
local Pet = script.Parent local Move = script.Parent:WaitForChild('Move') Move.OnServerEvent:connect(function(Player) if workspace[Player.Name] then local Head = workspace[Player.Name]:FindFirstChild('Head') if Head then Pet:SetPrimaryPartCFrame(CFrame.new(Head.CFrame.X + 1,Head.CFrame.Y + 2,Head.CFrame.Z + 1)) Pet:SetPrimaryPartCFrame(CFrame.new(Pet:GetPrimaryPartCFrame().p, Head.Position)); -- This is the changed place. end end end)
Thanks,
Best regards,
~~ KingLoneCat