Hello, I’m creating a Gui and I have this ImageButton with no image as a selection frame. But I have a problem with it, and that is, it’s always setting the position to {0,0},{0,0}.
Script:
-- Services
local RepStorage = game:GetService("ReplicatedStorage")
local ContentProvider = game:GetService("ContentProvider")
-- Variables
local MainFrame = script.Parent
local remote = RepStorage.RemoteEvents.ValueChanger
local maps = RepStorage.Maps:GetChildren()
local assets = {}
-- URL
local baseURL = "rbxassetid://"
-- Loop
for i, v in pairs (maps) do
table.insert(assets, i, baseURL..(v.ImgId.Value))
end
spawn(function()
ContentProvider:PreloadAsync(assets)
end)
for i, v in pairs (maps) do
local Frame = Instance.new("Frame", MainFrame)
Frame.Name = v.Name.." Map"
Frame.BackgroundColor3 = Color3.fromRGB(72, 72, 72)
Frame.Size = UDim2.new(0.13, 0,0.329, 0)
Frame.ZIndex = 10
local Text = Instance.new("TextLabel", Frame)
Text.BackgroundTransparency = 1
Text.Font = Enum.Font.GothamBold
Text.TextScaled = true
Text.Name = "MapName"
Text.Text = v.Name
Text.Size = UDim2.new(1, 0,0.306, 0)
Text.Position = UDim2.new(0, 0,0.653, 0)
Text.ZIndex = 15
local ImgLabel = Instance.new("ImageLabel", Frame)
ImgLabel.Size = UDim2.new(1, 0,0.694, 0)
ImgLabel.Image = baseURL..(v.ImgId.Value)
ImgLabel.ZIndex = 15
ImgLabel.Name = "Image"
local selectionFrame = Instance.new("ImageButton", Frame)
selectionFrame.BackgroundTransparency = 1
selectionFrame.Size = Frame.Size
selectionFrame.Position = Frame.Position
selectionFrame.ImageTransparency = 1
selectionFrame.ZIndex = 20
selectionFrame.Name = "SelectionFrame"
selectionFrame.MouseButton1Click:Connect(function()
remote:FireServer("SelectedMap", v.Name)
end)
Frame.LayoutOrder = i
end
I mean creating a new Frame, the automatic position is going to be {0,0},{0,0} so probably change this Frame’s position since you are redirecting the position of the ImageLabel to this Frame’s position or change it manually, here is an instance:
Did you find any solution? I have the same issue and I am 100% sure it’s not something related to coding because I am just trying to print a value and its neither printing nor giving any error. My text Button is active and selectable.