I want to achieve. Like when i press a button a ui pops up i’ve gotten that handled but if a player presses another button without exiting the other frame there will be 2 frames on the screen and it looks bad.
The issue is that the position of the frame gets set to 0,0,0,0 beacuse the UDim2.new(v.Position.X, 1.05, 0) is 0.379999995, 0 1.05 0 when i print it. It has no commas, so the thing errors and it becomes 0,0,0,0 and i’m wondering how can i make this, as i used v.Position.X beacuse not all frames in the for i, v in pairs loop has the same x akis position.
Here’s the script:
script.Parent.MouseButton1Click:Connect(function()
if Debounce == false then
Debounce = true
if SettingsOpen == false then
SettingsOpen = true
local ShopFrame = Player.PlayerGui.Settings.MainFrame
script.click_sound:Play()
ShopFrame:TweenPosition(
UDim2.new(0.358, 0,0.248, 0),
"In",
"Linear",
0.2
)
for i, v in ipairs(Player.PlayerGui:GetDescendants()) do
if v.Name == "MainFrame" and v.Parent.ClassName == "ScreenGui" and v.Parent.Name ~= "PlayerGui" and v.Parent.Name ~= ShopFrame.Name and v.Parent.Name ~= "GameShop" then
local X = v.Position.X
print(X)
v.Position = UDim2.new(X, 1.05, 0)
print(X, 1.05, 0)
end
end
else
SettingsOpen = false
local SettingsFrame = Player.PlayerGui.Settings.MainFrame
script.click_sound:Play()
SettingsFrame:TweenPosition(
UDim2.new(0.358, 0,1.05, 0),
"In",
"Linear",
0.2
)
end
wait(0.2)
Debounce = false
end
end)