New to tweening, what am I missing?

So, my goal is to have a portal spawn for 10 seconds, then disappear for 30 seconds so the player only has that 10 second window to touch it to get to the next area. (I know the timing in the script is off, it’s so I could easily test it.) but for some reason it’s not doing what’s needed. Is it the wait at the beginning? Thank you!

The script is as follows:

local part = script.Parent
local TS = game:GetService(“TweenService”)

local TweenInformation

wait(1)
TweenInformation = TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In)
local goal = {}
goal.Transparency = 1

local tween1 = TS:Create(part, TweenInformation, goal)

tween1:Play()

part.CanCollide = false
wait(5)

TweenInformation = TweenInfo.new(1.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local goal = {}
goal.Transparency = 0

local tween2 = TS:Create(part, TweenInformation, goal)

tween2:Play()

part.CanCollide = true

end

What is it doing now and what are you expecting it to do? This code seems fine as it is so I’m not entirely clear on where you’re having trouble.

2 Likes

Pretty much a fade in and a fade out type of deal is what I’m aiming for, what I think should happen with this script is it should wait the 1 second, perform the tween to make it invisible, then wait 5 seconds once it’s invisible, then repeat. But it doesn’t even start the process for some reason.

[22:35:28.267 - Workspace.portal.disappear:27: Expected , got ‘end’]

This is the output error.

You don’t need the end at the very bottom of the script, you can remove that. When a script encounters an error, the thread terminates - in this case, since you have that dangling end which isn’t closing a scope, it’s causing the script to error.