Trying to make a script to change the size and shape of parts

I am currently working on a project and need a script to change the size and shape of studs.

heres the script I’ve made so far,

script.Parent.Touched:Connect(function(hit) -- what touched it
	if hit.Name == ("Part") and 
      game.Workspace.Part.Shape == "Block" then -- check if it's name matches
		game.Workspace.Part.Shape = ("Sphere")  -- changes parts shape into a sphere
		game.Workspace.Part.Size = x == 1, y == 1, z == 1 -- changes the size to 1,1,1
	end
end)

I am a beginner at scripting, so the code itself is not great. Im not sure how to make it so that it only affects the parts that hit it. is there a way I can do this>

3 Likes

Use Vector3.new(X,Y,Z) like so:

workspace.Part.Size = Vector3.new(1,1,1)

Position and Size are Vector3 values.

Oh yeah I suggest to do some research into CFrames when you want to move parts and such around. The property is alike Position, only that it includes the Orientation and uses a different value called CFrame.

8 Likes

yo dude I see you tryna answer so many stuff, what do you get from the solution marks?

2 Likes

So if you were to make a script to change the Size of a part, you would need to use Vector3.new() to change it.

If the original size of a part was 1x1x1 studs, and you wanted to change it to 2x2x2 studs, you could do:

local part = game.Workspace.Part
part.Size = Vector3.new(2, 2, 2) -- X, Y, Z values in studs go in the parenthesis

To change the shape of the part, you would do this:

part.Shape = Enum.PartType.Ball -- to change it to a sphere/ball, but you could replace "Ball" with any valid shape
10 Likes

Pride, happiness and you can use it as part of your portfolio.

5 Likes

Sorry sir i dont wanna go down town

Wow you are gonna call me stupid like that, can somebody report this guy

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.