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

Why does my my part extend from both sides?

Asked by 7 years ago

So, I'm creating a Kamehameha wave, and when the beam is triggered to fire, both sides of the part expand. How do I fix this?

01script.Parent.Charge:Play()
02for i = 0.57, 2.16, 0.03 do
03    script.Parent.Size = Vector3.new(i,i,i)
04    wait(0.1)
05end
06beam = Instance.new("Part", script.Parent.Parent)
07beam.Name = "Beam"
08beam.Material = "Neon"
09beam.BrickColor = BrickColor.new(9,137,207)
10beam.Size = Vector3.new(0.99,1.77,2)
11beam.Shape = "Cylinder"
12beam.Anchored = true
13beam.Position = script.Parent.Position + Vector3.new(-0.825, 0.040, 0.022)
14script.Parent.Fire:Play()
15for i = 0.24, 18.5, 1.2 do
16    beam.Size = Vector3.new(i,1.77,2)
17    wait(0.05)
18end

1 answer

Log in to vote
1
Answered by 7 years ago

the part's position marks the center of the part, meaning if you were to change its size on, lets say a positive X axis, both sides would extend half the specified amount. to fix this, counteract it by moving forwards by half the amount you extended it

01--set up the part
02local brick = Instance.new("Part", workspace)
03brick.CFrame = CFrame.new(0,25,0)
04brick.Anchored = true
05 
06--ACTION
07 
08for i=0,100,1 do
09    wait()
10    brick.Size = Vector3.new(i,1,1)
11    brick.CFrame = CFrame.new(i/2,25,0)
12end
0
this would only extend one side correct? supercoolboy8804 114 — 7y
0
technically, both side are extending, you are just moving it to contract it and to simulate a different anchor point, so yes fanofpixels 718 — 7y
Ad

Answer this question