Hi, i created a script that rises a part, and whenever it reaches a certain amount of size, it makes the part the original size again and stops the growing. but it doesnt grow at all at the start.
i get this error:
while true do
wait(0.01)
Grow.Size = Grow.Size + Vector3.new(0.03,0,0)
Grow.Position = Grow.Position + Vector3.new(0,0.015,0)
if Grow.Size >= Vector3.new(82.476, 156.945, 135.364) then
Grow.Size = Vector3.new(7.028, 156.945, 135.364)
break
end
end
You can’t compare vector3s with those signs for engine reasons. Since you’re only changing the X, you can just compare the Size.X with 82.476 instead
Hi there, when the target size is reached this script should reset the size to the original size and break it out of the loop
local Grow = script.Parent -- Assuming the script is a child of the "Grow" part
local originalSize = Vector3.new(7.028, 156.945, 135.364)
local targetSize = Vector3.new(82.476, 156.945, 135.364)
local growthRate = Vector3.new(0.03, 0, 0)
local positionChange = Vector3.new(0, 0.015, 0)
while true do
wait(0.01)
local currentSize = Grow.Size
local newSize = currentSize + growthRate
local newPosition = Grow.Position + positionChange
if currentSize.magnitude < targetSize.magnitude then
if newSize.magnitude > targetSize.magnitude then
newSize = targetSize
end
Grow.Size = newSize
Grow.Position = newPosition
else
Grow.Size = originalSize
break
end
end
Yes, I meant for you to change line 43 from “Grow.Size.X = (7.028)” to “Grow.Size = Vector3.new(7.028, 156.945, 135.364)”. That “X” property is read only so you can’t make a new size like that
i have a question, do you know where i put in your script to also when the size resets to the original to change the position to 718.122, -13.29, 95.35?
The script will work when its inside the Grow part and I added the line Grow.Position = Vector3.new(718.122, -13.29, 95.35) after resetting the size. This will set the position of the “Grow” part to the specified coordinates when the size resets to the original.
local Grow = script.Parent -- Assuming the script is a child of the "Grow" part
local originalSize = Vector3.new(7.028, 156.945, 135.364)
local targetSize = Vector3.new(82.476, 156.945, 135.364)
local growthRate = Vector3.new(0.03, 0, 0)
local positionChange = Vector3.new(0, 0.015, 0)
while true do
wait(0.01)
local currentSize = Grow.Size
local newSize = currentSize + growthRate
local newPosition = Grow.Position + positionChange
if currentSize.magnitude < targetSize.magnitude then
if newSize.magnitude > targetSize.magnitude then
newSize = targetSize
end
Grow.Size = newSize
Grow.Position = newPosition
else
Grow.Size = originalSize
Grow.Position = Vector3.new(718.122, -13.29, 95.35) -- Reset the position
break
end
end