UDim2 not working properly?

Hello!

So I’ve been trying to make a Special Offer GUI in the corner of my players’ screens. I’ve used UDim2 methods, but the Size/Position is not set? It’s really getting on my nerves as I used pcalls and it’s never popping any errors up.

Thanks!

Edit:
Sorry, here’s my script:

local MarketPlaceService = game:GetService("MarketplaceService")
local GamepassID = 6613646
local BuyButton = script.Parent.BuyButton
local player = game.Players.LocalPlayer

BuyButton.MouseButton1Click:Connect(function()
	if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, GamepassID, false) then
		MarketPlaceService:PromptGamePassPurchase(player, GamepassID)
	end
end)

function create()
	print("hi")
	local leaf = Instance.new("ImageLabel", script.Parent)
	leaf.Name = "Leaf"
	leaf.Image = "http://www.roblox.com/asset/?id=4011208729"
	leaf.Position = UDim2.new({0.024, 0}, {0.141, 0})
	leaf.Size = UDim2.new({0, 100}, {0, 100})
	leaf.Visible = true
	leaf:TweenPosition(UDim2.new({0.008, 0},{0.225, 0}), Enum.EasingDirection.In, Enum.EasingStyle.Linear, 3, false, nil)
	wait(3)
        game.ReplicatedStorage.CreateLeaf:FireServer()
	leaf:Destroy()
end
game.ReplicatedStorage.CreateLeaf.OnClientEvent:Connect(create)

local success, message = pcall(create)

if message then
	print("An error occured with the LocalScript in Leaves GUI titled '" .. script.Name .. ".  Error - " .. message)
end

print("success!")
2 Likes

I don’t know if it makes a difference but you don’t need the {} in the UDim2.new() calls
just simply put UDim2.new(0.024, 0, 0.141, 0)

5 Likes

I actually said, “This isn’t gonna do anything, dude!”

then it worked

Haha, thanks so much!

2 Likes

No problemo, worked a lot with uis. :stuck_out_tongue: