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

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

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

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

1 comment

0

Not constructive at all.

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