Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is This Vector3.Size Part Functioning Correctly?

I had made this script in order to make it so that the part can decrease its size in order to open like a curtain does, but every time the curtains are placed in a contained area, they always go above all the other parts and they ignore the for loop which I was looking for it to slowly decrease the size of the curtain.

Curtain1 = game.Workspace.StageCurtain
Curtain2 = game.Workspace.StageCurtain2
StageFind1 = game.Workspace.StageCurtainFind

script.Parent.Parent.OPEN.MouseButton1Click:connect(function()
	
	for i = 31.56, 3.21, -.01 do
		Curtain1.Size = Vector3.new(i,27,0.23)
	end
	wait(0.1)
	Curtain1.Position = StageFind1.Position
end)

I have been having a go for quite a while and can't figure out why this is happening. Thanks.

1 answer

✓ Accepted answer

When you change the size of a part, it will automatically reposition the part upwards until it is not colliding with another part. A simple way to fix this is to try setting the CanCollide of the part to false before you resize it:

Curtain1 = game.Workspace.StageCurtain
Curtain2 = game.Workspace.StageCurtain2
StageFind1 = game.Workspace.StageCurtainFind

script.Parent.Parent.OPEN.MouseButton1Click:connect(function()

    for i = 31.56, 3.21, -.01 do
	Curtain1.CanCollide = false
        Curtain1.Size = Vector3.new(i,27,0.23)
	Curtain1.CanCollide = true
    end
    wait(0.1)
    Curtain1.CFrame = CFrame.new(StageFind1.Position)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.