So I have this local script in StarterPlayerScripts and since I will be using Tween Service a lot I made a little function that I can call whenever I want:
local function Tween(State, Subject, TweenInf, Property)
print(Property)
TweenService:Create(Subject, TweenInf, {Property = State}):Play()
end
The Subject is the part/UI you want to tween.
The TweenInf is the TweenInfo
The Property is the Property of the Subject thats changing
And The State is the Value the Property Is Changing to.
For e.g:
Subject = Part
TweenInf = TweenInfo.new(1)
Property = Part.Transparency
State = 1
But when I run the code I get this error:
no Property named 'Property' for object 'BlackScreen'
It seems like the code is thinking the value ‘Property’ is ‘Property’ but when I print it it comes out as (in this case) "BackgroundTransparency.
I need to remove this error and have the code correctly pick up what the value ‘Property’ actually is.
The issue you’re encountering is related to how you’re passing the Property parameter to the TweenService:Create function. In your current code, you’re passing a table with a single key named “Property,” and its value is the actual property you want to tween. This is causing the error because the Create function is expecting the property name directly.
By creating a table named properties and assigning the property name as a key with the desired state as its value, you provide the correct format for the Create function. Now, it should correctly recognize the property and perform the tween without errors.
local function Tween(State, Subject, Information, Property)
local Properties= {}
Properties[Property] = State
TweenService:Create(Subject, Information, properties):Play()
end