Hello! I am creating a pet system! This function is inside of a script in Server Script Service so when the pet is equipped this function will happen:
local character = player.Character
if pet ~= nil and character ~= nil then
if character:FindFirstChild(player.Name.."'s Pet") then character[player.Name.."'s Pet"]:Destroy() end
if character:FindFirstChild("attachmentCharacter") then
character("attachmentCharacter"):Destroy()
end
pet.Name = player.Name.."'s Pet"
pet:SetPrimaryPartCFrame(character.HumanoidRootPart.CFrame)
local modelSize = pet.PrimaryPart.Size
local attachmentCharacter = Instance.new("Attachment")
attachmentCharacter.Parent = character.HumanoidRootPart
attachmentCharacter.Name = "attachmentCharater"
attachmentCharacter.Visible = false
attachmentCharacter.Position = Vector3.new(0,-4,0) + modelSize
local attachmentPet = Instance.new("Attachment")
attachmentPet.Parent = pet.PrimaryPart
attachmentPet.Visible = false
local allignPosition = Instance.new("AlignPosition")
allignPosition.MaxForce = 25000
allignPosition.Attachment0 = attachmentPet
allignPosition.Attachment1 = attachmentCharacter
allignPosition.Responsiveness = 500
allignPosition.Parent = pet
local allignOrientation = Instance.new("AlignOrientation")
allignOrientation.MaxTorque = 25000
allignOrientation.Attachment0 = attachmentPet
allignOrientation.Attachment1 = attachmentCharacter
allignOrientation.Responsiveness = 500
allignOrientation.Parent = pet
pet.Parent = character
end
end```
Instead of doing what I have done I would rather it be like a simulator where they move more freely! How would I do that?? Thanks!