MouseEnter - Scale cannot be assigned to

Hello. I am trying to change a TextLabel Size (X.Scale) on MouseEnter Event but I get the error Scale cannot be assigned to. I tried to use UDim but I get the same error.
Original:


How it should look like:

Here is the script:

	for i = 1,100 do
		script.Parent.Line.Size.X.Scale = script.Parent.Line.Size.X.Scale + 0.001
		wait()
	end
end)

script.Parent.MouseLeave:Connect(function()
	for i = 1,100 do
		script.Parent.Line.Size.X.Scale = script.Parent.Line.Size.X.Scale - 0.001
	end
end)
3 Likes

Yep. You can’t assign values directly to the properties of a lot of (all of?) Roblox’s datatypes. The following snippet will also cause an error:

local v = Vector3.new(0, 0, 0)
v.X = 2 -- Error:  X cannot be assigned to

For your problem, the proper way to subtracting the scale is by constructing another UDim2, and subtracting it with that:

-- script.Parent.Line.Size.X.Scale = script.Parent.Line.Size.X.Scale - 0.001 -- This does not work
script.Parent.Line.Size = script.Parent.Line.Size - UDim2.new(0.001, 0, 0, 0) -- But this does!
12 Likes

You cannot assign the X and Y value individually. You must use UDim2.new(X Scale,X Offset, Y Scale, Y Offset)

In your case, it would be script.Parent.Line.Size = UDim2.new(script.Parent.Line.Size.X.Scale - 0.001, Put Your X Offset Here, Put Your Y Scale Here, Put Your Y Offset Here)

3 Likes