Use variables ahead of time?

Hello, is there any way you can use a variable ahead of time with a function? Here is my script:

	local scriptEnable = coroutine.create(function()
		wait(1.5)
		star.PrimaryPart.Script.Disabled = false
	end)
	local star = game.ReplicatedStorage.star:Clone()
	star.Parent = workspace
	star.PrimaryPart.Position = start
	scriptEnable()

You can use a variable after the wait by passing the variable to the function like so:

local scriptEnable = coroutine.create(function(star)
	wait(1.5)
	star.PrimaryPart.Script.Disabled = false
end)

local star = game.ReplicatedStorage.star:Clone()
star.Parent = workspace
star.PrimaryPart.Position = start

coroutine.resume(scriptEnable, star)

(SEE: coroutine as to why the last line was changed, its the coroutine you execute not that inhouse function, it does that for you!)

In this case I don’t know why you’d do it rather than just relocate the coroutine, but it’s called forward declaration.

    local star
	local scriptEnable = coroutine.create(function()
		wait(1.5)
		star.PrimaryPart.Script.Disabled = false
	end)
	star = game.ReplicatedStorage.star:Clone()
	star.Parent = workspace
	star.PrimaryPart.Position = start
	scriptEnable()

I’m a horrible programmer, I’m sorry.