there’s this part that i have, which constantly shrinks, using this script:
while true do
wait(1)
script.Parent.Size -= Vector3.new(0,0.02,0)
end
i’ve been using that shrinking part as a bar, which was supossed to kill the player if it got too low. but so far i’ve been having trouble detecting when the bar was too small.
local part = script.Parent
if part.Size.Y < 3.700 then
print("o2 works")
end
you can use vector3.Magnetude to compare size of a part
To make it trigger after it shrink to a certain size use GetPropertyChangedSignal()
which will look something like this
part:GetPropertyChangedSignal("Size"):Connect(function()
if part.Size.Magnitude < TargetSize.Magnitude then
--script here
end
end)
Full Script
local part = script.Parent
local ShrinkAmount = Vector3.new(.02,.02,.02)
local TargetSize = Vector3.new(3.7,3.7,3.7)
part:GetPropertyChangedSignal("Size"):Connect(function()
if part.Size.Magnitude < TargetSize.Magnitude then
--script here
end
end)
while true do
part.Size -= ShrinkAmount
wait()
end
alternatively if you want to shrink a part smoothly I recommend using TweenService() so you don’t need to run a loop and it is much easier