Soooo i have this code and wat its supposed to do is move the animal to the slot.Animal and place it on the slot as its standing on it it works but someitmes the animal js stands on the delivery box can someone help (im new into scripting go easy on me ;-;)
local function placeCharacterInSlot(player, clone)
local baseRec = _G.BaseManager.GetPlayerBase(player)
if not baseRec then return end
local floor1 = baseRec.instance:FindFirstChild("Floors"):FindFirstChild("Floor1")
if not floor1 then return end
local slotsFolder = floor1:FindFirstChild("Slots")
if not slotsFolder then return end
for i = 1, #slotsFolder:GetChildren() do
local slot = slotsFolder:FindFirstChild("Slot"..i)
if slot then
local platform = slot:FindFirstChild("Platform")
local animalFolder = slot:FindFirstChild("Animal")
local config = slot:FindFirstChild("Configuration")
local isTaken = config and config:FindFirstChild("IsTaken")
if platform and animalFolder and isTaken and not isTaken.Value then
isTaken.Value = true
for _, part in ipairs(clone:GetDescendants()) do
if part:IsA("BasePart") then
part.Anchored = true
end
end
clone.Parent = animalFolder
local modelCFrame, modelSize = clone:GetBoundingBox()
local modelBottomY = modelCFrame.Position.Y - (modelSize.Y / 2)
local platformTopY = platform.Position.Y + (platform.Size.Y / 2)
local deltaY = platformTopY - modelBottomY + 0.05
local newCFrame = CFrame.new(
platform.Position.X,
clone:GetPivot().Position.Y + deltaY,
platform.Position.Z
)
clone:PivotTo(newCFrame)
break
end
end
end
end