I have a function that runs periodically where essentially while tweening in, it will need to appear before the tween plays and conversely while tweening out, it will disappear after the tween plays.
The issue is that when it’s supposed to tween out, b.Transparency = 1 is running before the tween. Essentially, the object disappears before the tween plays
Aside from task.wait() i have also tried using wait() and tween.Completed:Wait() but the same thing happens
local function tweenArrow(obj, var, ti)
local tween = tweenService:Create(obj, ti, {Position = (obj.Parent:WaitForChild("origPosition").Value + Vector3.new(0, var, 0)) + (obj.Position - obj.Parent:WaitForChild("PrimaryPart").Position)})
tween:Play()
-- i don't think this is relevant
end
local function toggleInteractionArrow(obj, var, ti)
for _, a in pairs(obj:GetChildren()) do
if var == 0 and obj.Name ~= "PrimaryPart" then
a.Transparency = 0
end
task.spawn(tweenArrow, a, var, ti) --where the model/object tweens
end
if var ~= 0 then
task.wait(1)
for _, b in pairs(obj:GetChildren()) do
b.Transparency = 1
end
end
end
so if var is 0 then it’s tweening in which you can see with the a.Transparency = 0 the object appears before tweening
otherwise it’s tweening out but then again the object disappears before the tween