Im creating an obby where your an ice cube, you shrink over time and I have a wierd bug where they get flung? I can provide the script
print("MeltScript")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local originalSizes = {}
for _, part in ipairs(character:GetDescendants()) do
if part:IsA("BasePart") then
originalSizes[part] = part.Size
end
end
local scaleProperties = {
humanoid:FindFirstChild("BodyHeightScale"),
humanoid:FindFirstChild("BodyWidthScale"),
humanoid:FindFirstChild("BodyDepthScale")
}
local function updateSize()
local health = humanoid.Health
local maxHealth = humanoid.MaxHealth
local scaleFactor = (maxHealth > 0) and (health / maxHealth) or 0
for part, origSize in pairs(originalSizes) do
if part and part.Parent then
part.Size = origSize * scaleFactor
end
end
for _, scale in ipairs(scaleProperties) do
if scale then
scale.Value = scaleFactor
end
end
local rootPart = character:FindFirstChild("HumanoidRootPart")
if rootPart then
rootPart.Position = rootPart.Position - Vector3.new(0, (1 - scaleFactor) * 2, 0)
end
end
while character.Parent do
updateSize()
task.wait(0.1)
end