I’m trying to run a tween in a for loop to change the size of something, and if a certain condition is met stop that tween from running.
I’m having issues even getting the tween to run
Please help
Code:
local val = true
for i, v in pairs(spellreplicate.Beams:GetChildren()) do
if v.Name ~= "1" and v.Name ~= "2" then
local beam = spellreplicate.Beams:FindFirstChild(v.Name)
print(beam)
local beamgrow = tweenservice:Create(beam, TweenInfo.new(1), {Size = Vector3.new(beam.Size.X, 100, beam.Size.Z)})
beamgrow:Play()
local val2 = true
while val2 == true do
if beam.Touched == true and val2 ~= false then
local parts = beam:GetTouchingParts()
print(parts)
for i, v in pairs(parts) do
print(beam)
if v.Name == "Barrier" or v:IsA("Terrain") or v.Name == "Baseplate" then
beamgrow:Pause()
val = false
val2 = false
end
wait()
end
end
wait()
end
end
wait()
end
so, first of all, I believe that when you print beam print(beam) it will print “Instance”, so if you want the name put print(beam.Name), and what does .Touched stands for? if its a value inside the beam, you need to write beam.Touched.Value, and btw if you want to rlly make the tween stop and have no intention from playing it again on that call, you can just use Cancel instand of Pause
Send the output in here so I can rlly help you : )
It’s most likely not a value within the beam, but a misunderstanding of how to detect collisions with the beam. Due to how OP worded their issue, I am inclined to believe the tween runs occasionally, meaning their interpolation of the “Size” property works. Beams do not have this property, so one can assume his beam isn’t an actual beam
Oh I alr understood what he is try to do, we can just add a Touched function and delete that GeTouchingParts ig and I missunderstood beam, with bean sorry lol
That would lead to OP connecting an ever-increasing number of duplicate event listeners—that code would be executed in a loop. OP’s code is a mess, to be frank, so let’s try to write them a new script
So there is a model with a bunch of ‘beam’ PARTS under it. The for loop is going through the beam parts in that model. There are 8 beams total, and I do not want the function to check the first 2. Each beam has a number as it’s name. (1-8) The tween for beamgrow is meant to run a tween for each beam that is not 1 or 2 that increases the size of the part in question until the part touches the ground, baseplate, or a part with the name “Barrier”. The second for loop is what checks the parts touching IF the part has touched something. My issue is with getting the beamgrow tween to run in the first place.