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")
Hey! You should check out tweening here:
https://www.robloxdev.com/api-reference/function/GuiObject/TweenPosition
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)
Position.X is an integer, it doesn't have a 'Scale' property. Use Size.X instead.