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

How do i move gui 5 pixels away from its current position?

Asked by 2 years ago

I wanted to make menu for my game and to avoid diffrent resolution bugs i wanted to make gui move 5 pixels away from its position by doing this:

local START_POSITION = button.UDim2 == button.UDim2 + UDim2.new(0, 0, 0, 0)
local GOAL_POSITION = button.UDim2 == button.UDim2 + UDim2.new(1, 0, 1, 0) --yes i know this doesnt move gui 5 pixels away but ill change that later

but it doesnt work (If you still dont understand i want the button to move 5 pixels away from its current position so it can be anywhere on screen and still work correctly)

1 answer

Log in to vote
0
Answered by
imKirda 4491 Moderation Voter Community Moderator
2 years ago

the == thing compares if left value is equal to the right value:

print(20 == 20) -- true
print(40 == 20 + 20) -- true
print("kuba" == "fesak") -- false
print(game.Workspace == workspace) -- true
print(0.1 + 0.1 == 0.2) -- false (don't ask why)

in your case it's:

local START_POSITION = button.UDim2 == button.UDim2 + UDim2.new(0, 0, 0, 0)
-- equal to:
local START_POSITION = true + UDim2.new(0, 0, 0, 0)

which doesn't make any sense, you have to do:

local START_POSITION = button.UDim2 + UDim2.new(0, 0, 0, 0)
local GOAL_POSITION = button.UDim2 + UDim2.new(1, 0, 1, 0)
Ad

Answer this question