Unable to cast Array to TweenInfo

This is the function I’m running using
Animate(SprintButton, "Enter") and Animate(SprintButton, "Exit")

SprintButton is a TextButton while I’m also using SprintSpeed as a TextBox

They’re being fired whenever the mouse hovers over them, but the function keeps giving me the error in the title and doesn’t tween at all


local function Animate(Instance, State)
    local TweenInfo = {0.2, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, true}

    local InstanceInfo = {
        ["Enter"] = {},
        ["Exit"] = {}

    if Instance:IsA("TextButton") then
        InstanceInfo.Enter["BackgroundColor3"] = Color3.fromRGB(229, 241, 251)
        InstanceInfo.Enter["BorderColor3"] = Color3.fromRGB(0, 84, 153)

        InstanceInfo.Exit["BackgroundColor3"] = Color3.fromRGB(229, 229, 229)
        InstanceInfo.Exit["BorderColor3"] = Color3.fromRGB(176, 176, 176)
        InstanceInfo.Enter["BorderColor3"] = Color3.fromRGB(0, 102, 185)

        InstanceInfo.Exit["BorderColor3"] = Color3.fromRGB(27, 42, 53)


    if State == "Enter" then
        TweenService:Create(Instance, TweenInfo, InstanceInfo.Enter):Play()
        TweenService:Create(Instance, TweenInfo, InstanceInfo.Exit):Play()

How do I fix this?

You have to pass an array/table to TweenService:Create()

Something like this. I’m sure that you can only provide an instance for the first argument, so you might have to do multiple tweens.

local Exit = {BackgroundColor3 = Color3.fromRGB(229, 241, 251)}
TweenService:Create(InstanceInfo.Exit, TweenInfo, Exit):Play()

or this

TweenService:Create(InstanceInfo.Exit, TweenInfo, {BackgroundColor3 = Color3.fromRGB(229, 241, 251)}):Play()

I tried this and still didn’t work but I realized that TweenInfo was just a table and not trully TweenInfo. Instead of:

local TweenInfo = {0.2, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, true}

I changed it to this:

local TweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false)

This fixed my problem but thank you for your help.