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

Is anyone able to give an example how to use the "resize" function?

Hi, I recently posted a question here on how to code a part to change size in 1 direction. I was given the answer to use the "resize" function. The problem I'm having is that I do not know how to use the function, the wiki didn't have any examples either.

This is my script:

local MDoor = script.Parent
local handle = script.Parent.Parent.Handle
game.Players.PlayerAdded:connect(function(player)
	player.Chatted:connect(function(msg)
		if msg == "Open Door" then
			repeat
			MDoor.Size = MDoor.Size - Vector3.new(0, 1, 0)
			handle.Position = handle.Position - Vector3.new(0, 1, 0)
			wait(0.4)
			until 
			MDoor.Size == Vector3.new(36, 1, 2)
			and handle.Position == Vector3.new(1406, 16, 644.5)
		end
	end)
end)

I will greatly appreciate any form of help, Thanks!

2 answers

✓ Accepted answer

I did give an example but I can put it in the script. I thought the wiki was pretty clear. Resize is a function of parts where you supply a face (enum) and an increment. It is exactly like studio tools. I also recommend a better evaluation at the end.

local MDoor = script.Parent
local handle = script.Parent.Parent.Handle
game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if msg == "Open Door" then
            repeat
            MDoor:Resize(Enum.NormalId.Top,-1)
            handle.Position = handle.Position - Vector3.new(0, 1, 0)
            wait(0.4)
            until 
            MDoor.Size.y <= 1
            and handle.Position.y <= 16
        end
    end)
end)

1 comment

0

Thanks, I'm a very difficult learner I suppose that's why I found the Wiki unhelpful.

The wiki provides the following:

bool Resize (
    NormalId normalId,
    int deltaAmount
)

Basically, what this means, is that the normalId is what face you want to resize

Right = 0	
Top = 1	
Back = 2	
Left = 3	
Bottom = 4	
Front = 5

and the deltaAmmount is by how much.

As stated in, NormalId is a side, DeltaAmount is how much to grow/shrink on that side. The part won't be resized if there is a part blocking the facial direction.

Considering I am unaware of which faces you want to resize, I'll make a "general" example.

local partToResize = workspace.ResizeMe
for i = 1,10 do
	partToResize:Resize(Enum.NormalId.Top,i)
	partToResize:Resize(Enum.NormalId.Bottom,i)
	wait(1)
end

The above code will resize the part on the Y axis evenly, 1 stud each direction every second. I do not recommend this method as it will not pass through parts, it just stops.

3 comments

0

Yes I understand that bit, but my question is how would I use it in my script above? Am I supposed to use ":" or am I supposed to start a whole new function?

2

Kenza, i think you misunderstand. Resize IS the function. You don't have to create your own function, because roblox did it for you. The ':' means that you use it on an object, so you can do part:Resize()

0

Thank you both! ^_^

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