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

How do I Change a Text Label's Y Position?

Asked by 5 years ago
for p = .1,.15,.01 do

script.Parent.Parent.PlayerGui.bag_collected.bg.Position.Y = Vector2.new(p,0)

wait()

end

and it says Y cant be assigned to, i dont know how to fix this, its probably simple, but i cant figure it out, please help. Thanks :)

0
GUI's require U-Dimensional Size/Position assignments. Use UDim2.new() instead. Ziffixture 6913 — 5y
0
label.Position = label.Position + UDim2.new(0,0,0, 50) Change 50 to the number you would like it to move by. User#26586 0 — 5y
0
You should also be using TweenPosition as it'll create a smooth transition between your current and desired Position, with multiple styles too. Ziffixture 6913 — 5y

1 answer

Log in to vote
0
Answered by
starmaq 1290 Moderation Voter
5 years ago

You cannot assign the Y on its own, you gotta add to a new Udim2 value to the label's position, and that value will have X set to 0 so it doesn't effect the X axis for the label, but you can add more to the Y axis and that's by either adding scale or offset. And this is just a quick and this is jsut a little explanation. Udim2.new = (x, x1, y, y2)

| x | is the X scale | | x1 | is the X offset| | y | is the Y scale | | y1 | is the Y offset |

And of course if you wanna go deeper just search more!

Now instead of just changing the Y, do this:

local label = script.Parent.Parent.PlayerGui.bag_collected.bg
--I also assigned a variable that refers to your label just to make stuff easier.

for p = .1,.15,.01 do

    label.Position = Udim2.new(0,0,0,p)

    wait()

end

and that's it. Another thing is you can make this way cooler and smoother, as Fearhen said you can use :TweenPosition. You can check the different styles and paramaters that you can use with this function here. I would just be showing how to change the position.

local label = script.Parent.Parent.PlayerGui.bag_collected.bg

label:TweenPosition(Udim2.new(0,0,0,.15)
--as you can see were using a udim2 value here too. this is just an example, play with the numbers however you want to!

An example.

Ad

Answer this question