I'm trying to make a pet system, but I need to offset some of the pet's positions to fit more than one. Subtracting Vector3s from the position resulted in an offset based off of the player's angle, which is not what I wanted to make. Here is my current script:
local ss = game:GetService("ServerStorage")
local runs = game:GetService("RunService")
local pets = ss:WaitForChild("Pets")
local defaultPet = pets:WaitForChild("Noob")
local dist = 9
function givePet(plr,pet)
if plr then
local char = workspace:FindFirstChild(plr.Name)
if char then
local hrp = char.HumanoidRootPart
local newPet = pet:Clone()
newPet.Parent = char
local bodyPos = Instance.new("BodyPosition",newPet)
bodyPos.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
local bodyGyro = Instance.new("BodyGyro",newPet)
bodyGyro.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
runs.Stepped:Connect(function()
bodyGyro.CFrame = hrp.CFrame
bodyPos.Position = hrp.Position + -hrp.CFrame.LookVector*dist
end)
end
end
end
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
workspace:WaitForChild(plr.Name)
spawn(givePet(plr,defaultPet))
end)
end)
