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