Hi there!
I’m currently working on this game, which has a pet system, which essentially gives a player a boost. However, for some reason with some of the pets, they just fall straight through the map and get destroyed, but others don’t.
This is the current code that the system uses to equip a pet:
for n,pet in pairs(EquippedPets) do
if n > PlayerData.MaximumEquippedPets then continue end
local Attachment = Instance.new("Attachment")
Attachment.Parent = RootPetAttachments
Attachment.Name = tostring(n)
Attachment.Position = Vector3.new(PositionProperties[n%3],-1.5,math.round(((n+1) / 3))*3)
local PetModel = Service:FetchPetModel(pet)
if not PetModel then continue end
Attachment.Position = Vector3.new(PositionProperties[n%3],PetModel:GetAttribute("Type") == "Air" and 1.5 or -1.5,math.round(((n+1) / 3))*3)
PetModel = PetModel:Clone()
PetModel.Parent = Attachment
PetModel.PrimaryPart.Anchored = false
for _,part in pairs(PetModel:GetDescendants()) do
if part == PetModel.PrimaryPart then continue end
if part:IsA("BasePart") then
part.Anchored = false
end
end
local newAttachment = Instance.new("Attachment",PetModel.PrimaryPart)
newAttachment.Visible = false
task.defer(function()
local primary = PetModel.PrimaryPart
if primary then
local AlignPosition = Instance.new("AlignPosition")
AlignPosition.MaxForce = 25000
AlignPosition.Attachment0 = newAttachment --primary:FindFirstChildWhichIsA("Attachment") or Instance.new("Attachment",primary)
AlignPosition.Attachment1 = Attachment
AlignPosition.Responsiveness = 25
AlignPosition.Parent = PetModel
local AlignOrientation = Instance.new("AlignOrientation")
AlignOrientation.MaxTorque = 25000
AlignOrientation.Attachment0 = newAttachment --primary:FindFirstChildWhichIsA("Attachment") or Instance.new("Attachment",primary)
AlignOrientation.Attachment1 = Attachment
AlignOrientation.Responsiveness = 25
AlignOrientation.Parent = PetModel
end
end)
end
Everything is working, including the attachments, but for some reason, some of them just fall straight through the ground, but others don’t.
If anyone has any ideas, please let me know, thanks!