Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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")
0
minibar.Position = minibar.Position + UD2im.new(-0.01, 0, 0, 0) Vulkarin 581 — 5y
0
Thanks that works BeAHacker666 75 — 5y
0
No problem Vulkarin 581 — 5y

3 answers

Log in to vote
0
Answered by 5 years ago

Hey! You should check out tweening here:

https://www.robloxdev.com/api-reference/function/GuiObject/TweenPosition

0
If I helped, Please make sure to click that green tick box! UltraaaDev 85 — 5y
Ad
Log in to vote
0
Answered by
gullet 471 Moderation Voter
5 years ago

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)
Log in to vote
-1
Answered by 5 years ago

Position.X is an integer, it doesn't have a 'Scale' property. Use Size.X instead.

0
No? Position for GUIs is a UDim2 which contains "Scale" for X and Y https://www.robloxdev.com/api-reference/property/GuiObject/Position Vulkarin 581 — 5y

Answer this question