I’m experimenting with tweening and selection boxes and I’ve encountered an error.
I’ve tweened the selection boxes transparency to “fade in and out”, but my code is not waiting for the tween to finish, skipping the wait() and changing the Adornee, can someone look at it the code and see what’s wrong:
mouse.Move:Connect(function()
local Target = mouse.Target
if equipped then
if mouse.Target ~= nil then
local humanoid = mouse.Target.Parent:FindFirstChild("HumanoidRootPart")
if humanoid then
if tween and tweening then
tween.Completed:Wait()
end
SelectionBox.Adornee = humanoid
tween = TweenService:Create(SelectionBox, TweenInfo.new(1), {Transparency = 0.3})
tween:Play()
else
tween = TweenService:Create(SelectionBox, TweenInfo.new(1), {Transparency = 1})
tweening = true
tween:Play()
tween.Completed:Wait()
SelectionBox.Adornee = nil
tweening = false
end
end
end
end)