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

UDim2.new Coordinates Do Not Go To Position?

Asked by 5 years ago
Edited 5 years ago

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)
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. INOOBE_YT 387 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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.

Ad
Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago

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)
0
._. User#19524 175 — 5y

Answer this question