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

UDim2.new Coordinates Do Not Go To Position?

So I am working on a map basically however I have a button that is intended to recenter the map into the specified position: {0.5, -1000},{0.5, -550} which is the position of the Frame when the game starts. Whenever I click the button though, the Frame goes to {0,0},{0,0}. Why does it not go to the specified position and does it have to do with screen resolution?

script.Parent.MouseButton1Click:connect(function()
  script.Parent.Parent.Parent.Map.Position = UDim2.new{0.5, -1000},{0.5, -550}
end)

1 comment

0

You should only use the first parameter of each axis, the second one is based off of pixels and not the resolution of the monitor. The second one could make guis get cut off or overlap if someone uses another resolution.

2 answers

✓ Accepted answer

###The problem is the curly braces. UDim2 values aren’t tables. Wrap the numbers in a pair of brackets. To answer your question if it has to do with resolution: no.

local map = script.Parent.Parent.Parent.Map

script.Parent.MouseButton1Click:Connect(function()
    map.Position = UDim2.new(.5, -1000, .5, -550)
end)

###On a side note, switch to RBXScriptSignal:Connect(), as ROBLOX may remove RBXScriptSignal:connect() in the future.

Because you're not supposed to use curly paranthesis - You're supposed to use paranthesis.

script.Parent.MouseButton1Click:Connect(function()
        script.Parent.Parent.Parent.Map.Position = UDim2.new(0.5, -1000, 0.5 -550)
end)

1 comment

0

._.

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