How do i tween property values?

So, i’m trying to tween a property of an instance to smoothly change.

but i’m not sure what i’m doing wrong, i can’t seem to get it to work.

image

Some help on how to solve this issue will be very much appreciated as always

-- Variables --

local DOFEffect = game.Lighting:WaitForChild("DepthOfField")
local TweenService = game:GetService("TweenService")

local LoadTime = script.Parent.Parent.Parent.LoadTime
local Activate = script.Parent.Activate

-- Load --

wait(LoadTime.Value)

-- Function --

function ChangeDOFEffect(PropertyToModify, PropertyGoal, Tween, TweenDuration, EasingStyle)
	
	if Tween then
		local function TweenEffect()
		    local TI = TweenInfo.new(TweenDuration, EasingStyle, Enum.EasingDirection.In, 0) -- 5 = Duration, Style, Type, Repeat how many times
		    local Animation = TweenService:Create(DOFEffect, TI, {PropertyGoal = PropertyGoal})
		    Animation:Play()
		end
		
		TweenEffect()
	else
		PropertyToModify = PropertyGoal
	end
end

-- Start --

repeat wait() until Activate.Value == true

ChangeDOFEffect(DOFEffect.FocusDistance, 20, true, 1, Enum.EasingStyle.Linear)

-------------
1 Like

The message is self explanatory: there is no PropertyGoal property for the DepthOfField object.

What property are you trying to tween?

The third argument of :Create() is a table of properties and their goal [PropertyName] = [Goal]. So it should be TweenService:Create(DOFEffect, TI, {FocusDistance = 20})

2 Likes

image

ohh, i see. Thank you for your help!