I am making a “Grow a garden” type of game, but with animals.
The problem occurs when the player places an egg, out of which the animal comes out. The animal usually works just fine and gets spawned in, but in rare occasions, it falls through the ground.
I’ve tried searching, thinking, a lot of ChatGPT… but nothing worked. I made all of the parts in my model massless, CanCollide off and Anchored Off.
local originalSize = egg.Size
local targetSize = egg.Size * 2
local yOffset = (targetSize.Y - originalSize.Y) / 2
local growGoal = {Size = targetSize, CFrame = cFrame * CFrame.new(0, yOffset, 0)}
local animal = SS.Animals:WaitForChild(animal):Clone()
for _, part in ipairs(animal:GetDescendants()) do
if part:IsA("BasePart") then
part.CollisionGroup = "Animal"
part.Massless = true
end
end
local animalHeight = animal.PrimaryPart.Size.Y
local spawnCFrame = egg.CFrame + Vector3.new(0, egg.Size.Y / 2 + animalHeight / 2 + 0.4, 0)
animal:PivotTo(spawnCFrame)
TW:Create(egg, TweenInfo.new(1.25, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0, false, 0.15), growGoal):Play()
task.wait(1.25)
TW:Create(egg, TweenInfo.new(.1), {Size=Vector3.new(0,0,0)}):Play()
local particles = RP.Confetti:Clone()
particles.CFrame = egg.CFrame
particles.Parent = game.Workspace
local n = math.random(1, 1000)
local result = getRandomRarity(n)
local scale = Animal.Round(result.scale)
local price = Animal.Round(scale * animal.Price.Value)
local mutation = math.random(1,100)
if mutation == 100 then
price = Animal.Round(price * 5)
animal.Mutation.Value = "RAINBOW"
elseif mutation >= 97 then
price = Animal.Round(price * 3)
animal.Mutation.Value = "GOLDEN"
end
Mutations.applyMutation(animal.Mutation.Value, animal)
animal.Price.Value = price
animal.PrimaryPart.Animal.Frame.Value.Text = price .."$"
animal.Scale:SetAttribute("targetScale", scale)
animal.Parent = plr.Plot.Value.Animals
task.wait(0.1)
Any help is greatly appreciated!