X cannot be assigned to

I am trying to make a cash icon appear next to the amount you have. I read you could use textbounds on another devforum post.

This is my current code but it keeps giving the error, “X cannot be assigned to”

local player = game.Players.LocalPlayer
local tix = player.Values.Tix
local image = script.Parent.ImageLabel

local textBounds = script.Parent.TextBounds.X

task.wait(0.5)

script.Parent.Text = "Tix: "..tix.Value
image.Position.X = Vector3.new(textBounds,0)

tix.Changed:Connect(function()
	script.Parent.Text = "Tix: "..tix.Value
	image.Position.X = Vector3.new(textBounds,0)
	game.Workspace.Sounds.Coin:Play()
end)

Thank you for your help!

2 Likes

You cannot assign to the X property because it is read-only, you need to construct a new UDim2 type and assign that to the Position

UDim2.new(<XScale>, <XOffset>, <YScale>, <YOffset>)

You look like you’re trying to do this:

UDim2.new(textBounds, 0, yScale, yOffset)
4 Likes

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