Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is This Vector3.Size Part Functioning Correctly?

Asked by 6 years ago

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

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

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)
Ad

Answer this question