Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

inventory script not working ("X cannot be assigned to")? [Fixed]

i was making a inventory script for my game but on line 13 21 36 it gives a error X cannot be assigned to

local IOS = 0
local Ys = {0.027, 0}
local Xs = {0.039, 0}
local placeholeder = script.Parent.Parent.ITEMNAMERHERE
function items()
	for _, child in pairs(script.Parent:GetChildren()) do
		if child.Name ~= "Itmesscripts" then
			child:Destroy()
		end
	end
	for _, child in pairs(game.Players.LocalPlayer.Items:GetChildren()) do
		if child.Value > 0 then
			placeitem(child.Name)
		end
	end
end

function placeitem(NAME)
	local itme = placeholeder:Clone()
	itme.Parent = script.Parent.Parent.ScrollingFrame
	itme.Position.X = Xs
	itme.Position.Y = Ys
	IOS = IOS + 1
	if Xs == {0.039, 0} then
		Xs = {0.493, 0}
	else 
		Xs = {0.039, 0} 
		Ys[1] = Ys[1] + 0.078
	end
	local amout = game.Players.LocalPlayer.Items[NAME].Value
	itme.TextLabel.Text = NAME .. "\N" .. amout
	placeholeder.Visible = true
end

while true do
	items()
	wait(1)
end

1 answer

✓ Accepted answer

This is an issue I recently ran into myself. You can't seem to directly assign just X or just Y. You have to use a Udim2.new and assign the position for both X and Y together. So for example:

local XYs = Udim2.new(.027,0, .039, 0)

local itme.Position = XYs

I'm not sure if there is a work around this exactly but this is the same issue I ran into a few days ago and that's the only way I could find to actually set the position of Gui related stuff.

This discussion is preserved as it was. New answers, comments, and votes are closed.