Expected identifier when parsing expression, got '='

I know there are multiple topics on this same error but I scrolled through quite a few of them and none of them were closely related to my situation

Basically I’m trying to set a parts transparency under a variable and I’m getting an error message saying that = is an invalid parsing expression

Here is my script:

local ts = game:GetService("TweenService")

local players = game:GetService("Players")
local player = players:FindFirstChild("LocalPlayer")

local producer = script.Parent.Parent.producer
local producerChildren = producer:GetChildren()

local button = script.Parent


button.Touched:Connect(function()
	local function producerTween()
		for i,v in pairs(script.Parent.Parent.producer:GetDescendants()) do
			local producerInfo = TweenInfo.new(
				0.5, -- time
				Enum.EasingStyle.Linear, -- easing style
				Enum.EasingDirection.InOut, -- easing direction
				0 ,-- repeat count
				false, -- reverses
				0 -- delay
			)
			
			local producerGoal = v.Transparency = 1
			
			local producerTween = ts:Create(v, producerInfo, producerGoal)
			producerTween:Play()
		end
	end
	
	
	local buttonInfo = TweenInfo.new(
		0.5, -- time
		Enum.EasingStyle.Linear, -- easing style
		Enum.EasingDirection.InOut, -- easing direction
		0 ,-- repeat count
		false, -- reverses
		0 -- delay
	)
	
	local buttonGoal = button.Transparency = 1
	
	local buttonTween = ts:Create(button, buttonInfo, buttonGoal)
	
	
	producerTween()
	buttonTween:Play()
	
	
	task.wait(.5)
	
	
	button.CanTouch = false
end)

The error is on lines 24 and 41 so I expect I’m doing something wrong instead of a typo and since I’m relatively new to programming any feedback would be appreciated

Edit: Turns out the embedded code doesnt show the line numbers so the errors are popping up on the lines with the variable names containing Goal in them (producerGoal and buttonGoal)

1 Like

I also misplaced some commas and I fixed them but to no avail

The “goal” when creating a Tween is meant to be contained within a table in the following format:

local goal = {
    PropertyNameToChange = EndValue
}

This means that you would need to update the producerGoal variable to something like this for it to work as intended:

local producerGoal = {Transparency = 1}

The same thing applies for the buttonGoal later on in the script:

-- Current
local buttonGoal = button.Transparency = 1

-- Revised
local buttonGoal = {Transparency = 1}
1 Like

Thanks! I remember for a previous tween a while back I directly set the goal instead of using a variable and I remember struggling with the braces so this makes perfect sense

1 Like

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