If you want to make the part stay in place but increase size, then it's important to know that: when you add X amount of size, the relativity for positioning it is 1/2 X. But since you want the part to go down,
read the following:
If you want the part to go down, but you don't want it to go through the baseplate, use an if statement, like so:
wait(.5)
while wait() do
for i,v in pairs(script.Parent.Parent:GetChildren()) do
if v.Name ~= "FieldTouch" then
if v.Health.Value < 2 then
local median = (v.Size.Y - v.Health.Value)
v.Size = v.Size - Vector3.new(0,median,0)
if v.Position.Y - median >=1 then
v.Position = v.Position - Vector3.new(0,median,0)
else
v.Position = v.Position - Vector3.new(0,median / 2,0)
end
end
end
end
end
What that does, is if the part is shrinking and going down and about to go through the baseplate, then it will make it only shrink and not go down.
Let me know if this worked by accepting my answer! If it still didn't work, or you have trouble understanding something, leave a comment and I will reply.
1 comment
Thanks for the answer but there is still a problem, depending on how much damage the tool did, it will either go to the middle or go down but still position through the baseplate after the health is 0.