# If/else Statement Formating done wrong

Hi there, I have a simple problem with the formating in an if/else:

``````if newTicket.Position == {0.023, 0},{0.193, 0} then
newTicket.Position = {0.192, 0},{0.193, 0}
end
``````

The very first line is wrong and the coma between {0.023, 0} and {0.193, 0} is red and doesn’t seem to work… How do I need to format it in order for it to work ?
I tired it this way but it didn’t appear to work:

``````if newTicket.Position == {0.023, 0, 0.193, 0} then
``````

I’m sure you’re familiar with that saying in math, 'to compare or combine, they must be the same kind."

In this setting, we have to make sure we’re comparing two of the same data types.

Generally, when I compare UI positions, I always do axis-for-axis, like in this example:

``````if element1.Position.Y.Scale == element2.Position.Y.Scale then --//both of these are numbers, so that'll work fine!
print'blah'
end
``````

Hope that helps.

1 Like

Thanks for your reply ! Would that then mean I’d have to do something like that?

``````if element1.Position.Y.Scale == element2.Position.Y.Scale and element1.Position.X.Scale == element2.Position.X.Scale then
``````

Assuming `newTicket` is a UI, this means `newTicket.Position` has to be a UDim2 value, it’s true that a UDim2 is composed of 2 tables, but you can’t just put two tables like that, you have to actually create a UDim2 value.

``````if newTicket.Position == UDim2.new({0.023, 0},{0.193, 0}) then
newTicket.Position = UDim2.new({0.192, 0},{0.193, 0})
end
``````

Also, the two tables are not needed, you can just do `UDim2.new(0.192,0,0.193,0)`

4 Likes

Hello ! I know I’m "“bringing back to life” this topic, but I’ve tried everything you guys said and it doesn’t seem to work… Here is the full code with notes.

``````MPS = game:GetService("MarketplaceService")

MPS.ProcessReceipt = function(receiptInfo)

if receiptInfo.ProductId == 967538409 then -- works
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)

local regularTicket = player.Tickets.RegularTicketAmount
local totalTicket = player.Tickets.TotalTicketAmount

regularTicket.Value = regularTicket.Value + 1
totalTicket.Value = totalTicket.Value + 1

if totalTicket.Value == 1 then -- works
-- the only line which doesn't work is the one bellow, but the output doesn't say anything about it...
newTicket:TweenPosition(UDim2.new(0.192, 0, 0.193, 0)) -- this line doesn't work
end

return Enum.ProductPurchaseDecision.PurchaseGranted

end
end
``````

thank you !

Are you sure that that’s perhaps not the same position the UI is in?

1 Like

It’s not, I thought of that and double checked, and its not… I tried debugging it with print statements but that appears to be the only wrong line…

Perhaps I’m wrong, and the array form is needed. Try `UDim2.new({0.192, 0}, {0.193, 0})`

It isn’t needed, I’ve been doing it without brackets for a while.

1 Like

I have just tried that and it sadly didn’t work…

Otherwise I’d try to use TweenService for that.

How would I use that exactly? (30 characters)

``````MPS = game:GetService("MarketplaceService")
local TS = game:GetService("TweenService")
local info = TweenInfo.new(1) -- Duration of tween
MPS.ProcessReceipt = function(receiptInfo)

if receiptInfo.ProductId == 967538409 then -- works
local player = game.Players:GetPlayerByUserId(receiptInfo.PlayerId)

local regularTicket = player.Tickets.RegularTicketAmount
local totalTicket = player.Tickets.TotalTicketAmount

regularTicket.Value = regularTicket.Value + 1
totalTicket.Value = totalTicket.Value + 1

if totalTicket.Value == 1 then -- works
local tween = TS:Create(newTicket, info, {Position = UDim2.new(0.192, 0, 0.193, 0)})
tween:Play()
end

return Enum.ProductPurchaseDecision.PurchaseGranted

end
end
``````

This should work.

Just tried that and it still doesn’t work, although I’m sure that’s the problem since everything else works.

The issue I’m seeing is that the gui action is done on the server, which does not have access to the player’s gui. Also this line:

``````local newTicket = game.StarterGui.Menu.Frame.NewTicket
``````

does not use the player’s gui, it uses the gui that is assigned to any new player that joins the game. In short, it does nothing to player that bought the ticket.

I think it can, I’ve been changing it from the server for a while before I learned it’s better to do it from the client.

With filtering enabled? I assume he would want it with filtering enabled since he is checking for purchases to make sure the player is not exploiting.

Nevermind, guess I had filtering enabled off.

Alright, I think I see the problem, but what would I have to do in order to ix it? My PurchaseHandler is currently in ServerScriptService and is a regular script. Would I have simply have to make it a local script?

So would I have to change this line to

``````local newTicket = game.Player.LocalPlayer.PlayerGui.Menu.Frame.NewTicket
``````

?