Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why am I unable to cast this tween?

Asked by 5 years ago

So, I have a simple script that tweens a GUI frame's background color. For some reason I get an error saying the tween was unable to be cast. Here's my script:

local TweenService = game:GetService("TweenService")
local LoadingScreenGui = script.Parent
local Background = LoadingScreenGui:WaitForChild("Background")
local TransitionTime = 1
function TweenObject(object,goal,t)
    local tweenInfo = TweenInfo.new(1)
    print(type(object),type(goal),type(tweenInfo))
    local tween = TweenService:Create(object,goal,tweenInfo)
    tween:Play()
end
local goal = {}
goal.BackgroundColor3 = Color3.new(1,1,1)
TweenObject(Background,goal,TransitionTime)

I could really use some help with this.

1
You got your arguments incorrect on line 8. It should be like this: local tween = TweenService:Create(object,tweenInfo,goal) saSlol2436 716 — 5y
0
Yep thanks Wafflecow321 457 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

In line 11, you set the goal table to blank.

local goal = {
    BackgroundColor3 = Color3.fromRGB(r, g, b) 
}

Set the r g b to your colours.

0
I gave the table a value in line 12. Wafflecow321 457 — 5y
0
Oof didn’t see it. User#19524 175 — 5y
Ad

Answer this question