GUI goes in wrong position if it doesnt get product info

Okay so, basically im currently trying to make a system where if you hover your mouse over a surface gui product, it will move a ui towards your mouse showing what you will recieve from buying it. It seems that without a single line of code (which gets the product info) it will not go to the mouse position. Im not sure why so i would appreciate if someone could help me.

v.MouseEnter:Connect(function()
			local price = game:GetService("MarketplaceService"):GetProductInfo(v.AssetId.Value).PriceInRobux -- IF GET PRODUCT INFO IS REMOVED IT WILL NOT GO TO THE MOUSE POSITION
			local conversion = math.round(price / game.ReplicatedStorage.RobuxToCoinConversion.Value)
			local mouse = game.Players.LocalPlayer:GetMouse()
			script.Parent.MainPopups.Position = UDim2.new(0, mouse.X , 0, mouse.Y)
			script.Parent.MainPopups.Price.Text = price
			script.Parent.MainPopups.Coins.Text = conversion.." coins"
			script.Parent.MainPopups.Visible = true
			activeonbutton = true
			button = v
		end)
2 Likes

Without that line of code, you dont get the ‘price’ value. Which means youll be trying to do math on ‘price’ that is nil, resulting in errors. That halts the function there and the gui never gets to be repositioned

We lined out everything except

local mouse = game.Players.LocalPlayer:GetMouse()
script.Parent.MainPopups.Position = UDim2.new(0, mouse.X , 0, mouse.Y)
script.Parent.MainPopups.Visible = true

but it still results in the position being at the top left of the screen.