I am trying to make a pet follow system but the orientation is off!
Here are the scripts :
-- // Variables \\ --
Instance.new("BodyPosition",script.Parent)
Instance.new("BodyGyro",script.Parent)
local Pet = script.Parent
local Settings = require(Pet.Settings)
game.Players.PlayerAdded:Connect(function(plr)
wait(5)
script.Parent:Clone().Parent = plr.Character
end)
-- // Defaults \\ --
do
local Owner = script.Parent.Parent
if Owner then
local Target = Owner:FindFirstChild("HumanoidRootPart")
if Target then
Pet.CFrame = Target.CFrame + CFrame.new() * Vector3.new(Settings.xDist, Settings.yDist, Settings.zDist)
end
end
end
Pet.BodyPosition.P = Settings.MovePower
Pet.BodyGyro.P = Settings.RotPower
-- // Main \\ --
Pet.Orientation = Settings.Orientation
while wait(Settings.UpdateDelay) do
local Owner = script.Parent.Parent
if Owner then
local Target = Owner:FindFirstChild("HumanoidRootPart")
if Target then
--[[Pet.BodyPosition.Position = Target.Position
Pet.BodyGyro.CFrame = Target.CFrame + Vector3.new(Settings.xDist, Settings.yDist, Settings.zDist)--]]
Pet.CFrame = Target.CFrame + CFrame.new() * Vector3.new(Settings.xDist, Settings.yDist, Settings.zDist)
end
end
end
local Settings = {
UpdateDelay = 0, -- Delay in Seconds for the Pet to Update (nil = 0.003 Seconds)
MovePower = 9, -- Power Required to Move
RotPower = 3000, -- Power Required to Rotate
xDist = 1, -- Horizontal Distance on the X-Axis to Stop from the Player (Studs)
yDist = 0, -- Vertical Distance on the Y-Axis to Stop from the Player (Studs)
zDist = 1, -- Horizontal Distance on the Z-Axis to Stop from the Player (Studs)
Orientation = Vector3.new(0, 0, 0), -- How much to rotate
}
return Settings
Here is a video :
Any help is appreciated!