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

Why does my part extend in both the negative and positive X angles?

Asked by 6 years ago

I'm trying to make a ki beam, and I've gotten everything else handled except for the beam. It fires in the correct position, but both sides of the part extend. How would I go about fixing this? My code:

script.Parent.Charge:Play()
for i = 0.57, 2.16, 0.03 do
    script.Parent.Size = Vector3.new(i,i,i)
    wait(0.1)
end
beam = Instance.new("Part", script.Parent.Parent)
beam.Name = "Beam"
beam.Material = "Neon"
beam.BrickColor = BrickColor.new("Electric blue")
beam.Size = Vector3.new(0.99,1.77,2)
beam.Shape = "Cylinder"
beam.Anchored = true
beam.CanCollide = false
beam.Position = script.Parent.Position + Vector3.new(-0.825, 0.040, 0.022)
script.Parent.Fire:Play()
for i = 0.24, 18.5, 1.2 do
    beam.Size = Vector3.new(i,1.77,2)
    wait(0.05)
end

2 answers

Log in to vote
0
Answered by
H4X0MSYT 536 Moderation Voter
6 years ago
Edited 6 years ago

Since you are increasing the size of the part; and not the position; the part expands but is still located centrally to that same position. In order to do this, if you were using this code to increase size:

beam.Size = Vector3.new(i,1.77,2)

you would want to also change the position. If I increase any axis of a parts size by 1, each side will gain + 0.5 studs. If x is 1, we would want to modify the position by half of x. In your case, x will be different. So you would need to implement this:

for i = 0.24, 18.5, x do
    beam.Size = Vector3.new(1, 1.77, 2)
    beam.Position = beam.Position + Vector3.new(x / 2, 0, 0)
end
Ad
Log in to vote
-1
Answered by 6 years ago
script.Parent.Charge:Play()
for i = 0.57, 2.16, 0.03 do
    script.Parent.Size = Vector3.new(i,i,i)
    wait(0.1)
end
beam = Instance.new("Part", script.Parent.Parent)
beam.Name = "Beam"
beam.Material = "Neon"
beam.BrickColor = BrickColor.new("Electric blue")
beam.Size = Vector3.new(0.99,1.77,2)
beam.Shape = "Cylinder"
beam.Anchored = true
beam.CanCollide = false
beam.Position = script.Parent.Position + Vector3.new(-0.825, 0.040, 0.022)
script.Parent.Fire:Play()
for i = 0.24, 18.5, 1.2 do
    beam.Size = Vector3.new(i,1.77,2)
    beam.Position = beam.Position - Vector3.new(1,0,0)
    wait(0.05)
end
0
Not constructive at all. H4X0MSYT 536 — 6y

Answer this question