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

How to make a GUI move animation? It keeps giving me the error: "Scale cannot be assigned to"

I'm trying to make my GUI move. But it always tells me "Scale cannot be assigned to". IDK why cuz it should work right? Here's my code:

local minibar = script.Parent

function show()
	while (minibar.Position.X.Scale > 0.8) do
		minibar.Position.X.Scale = minibar.Position.X.Scale - 0.01
		wait()
	end
end

function hide()
	while (minibar.Position.X.Scale < 1) do
		minibar.Position.X.Scale = minibar.Position.X.Scale + 0.01
		wait()
	end
end

print("wait3") -- So it doesn't start directly
wait(3)
show()
print("wait1") -- Stops animation for 1 second
wait(1)
hide()
print("wait0")

3 comments

0

minibar.Position = minibar.Position + UD2im.new(-0.01, 0, 0, 0)

0

Thanks that works

0

No problem

3 answers

No it shouldn't work because as the error said, scale cannot be assigned to. You need to create a new UDim2 object to assign to Position, you cannot change the values of an existing one. Their values can however be read (otherwise what would be the point?). As the wiki documents you can use the + operator that returns a new UDim2.

minibar.Position = minibar.Position + UDim2.new(0.01,0,0,0)

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