ViewportFrame's tweened ImageTransparency was unable to cast value to Object

Hello,

I want to make an image fade out cilentside using Tweens via a local script. Here’s a pseudocode of what I had been doing so far and the error I had ran into:

image

local player = game.Players.LocalPlayer
local pGui = player:WaitForChild("PlayerGui")
local tweenS = game:GetService("TweenService")
local vFrame = pGui:WaitForChild("ViewportFrame").ImageTransparency

local function FadeOut(Image, Duration)
	local Tween = tweenS:Create(Image, TweenInfo.new(
		Duration,
		EasingStyle,
		EasingDirection,
		), {Transparency = 1})

	Tween:Play()
end

FadeOut(vFrame, 1)

Any help/advice would be appreciated and I will do my best to clarify as this is my first post on the forums.

2 Likes

Hi,

You’ll need to Tween the actual object itself rather than the property “ImageTransparency”.

You could try doing this:

local player = game.Players.LocalPlayer
local pGui = player:WaitForChild("PlayerGui")
local tweenS = game:GetService("TweenService")
local vFrame = pGui:WaitForChild("ViewportFrame")

local function FadeOut(Image, Duration)
	local Tween = tweenS:Create(Image, TweenInfo.new(
		Duration,
		EasingStyle,
		EasingDirection,
		), {ImageTransparency = 1})

	Tween:Play()
end

FadeOut(vFrame, 1)

Hope this helps!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.