Hello, I have a few little problems and it’s do with the gui tweeing not repeating itself correctly after 2-3 tries.
Video:
https://streamable.com/prhiag
As you can see, on the 3rd try the tweeing fails.
After stopping recording, the high light menu only appeared not the alert. I’m not sure what breaks when you continously press the button.
Main code of issue:
alert = white highlight box around the item id box
Alerts = alert that pops in the bottom left
Full Code:
local Player = game.Players.LocalPlayer
local MarketService = game:GetService("MarketplaceService")
local IDBox = script.Parent.Parent.IDInput
local ConfirmPurchase = script.Parent.Parent.confirm
local TextConfirm = script.Parent.Parent.texxt
local ID
local green = script.Parent.Parent.texxtminus
local alert = script.Parent.Parent.alert
IDBox.FocusLost:Connect(function()
ID = IDBox.Text
end)
ConfirmPurchase.MouseButton1Down:Connect(function()
if ID ~= nil then
local SuccessCheck, NotValid = pcall(function()
MarketService:PromptPurchase(Player, ID)
end)
if SuccessCheck then
print(Player.Name.." has inserted a valid Catalog ID")
else
script.Parent.Parent.Alerts.TextBox.Text = "That's not a valid Catalog ID!"
script.Parent.Parent.Alerts.Visible = true
script.Parent.Parent.Alerts:TweenPosition(
UDim2.new(0.06,0,0.738,0),
"In",
"Bounce",
.5,
false
)
wait(3)
script.Parent.Parent.Alerts:TweenPosition(
UDim2.new(-0.237, 0,0.738, 0 ),
"Out",
"Bounce",
.5,
false
)
wait(3)
script.Parent.Parent.Alerts.Visible = false
end
else
--- if no value
alert.Visible = true
script.Parent.Parent.Alerts.TextBox.Text = "Please enter the ID of the item in the box first"
script.Parent.Parent.Alerts.Visible = true
script.Parent.Parent.Alerts:TweenPosition(
UDim2.new(0.06,0,0.738,0),
"In",
"Bounce",
.5,
false
)
wait(3)
script.Parent.Parent.Alerts:TweenPosition(
UDim2.new(-0.237, 0,0.738, 0 ),
"Out",
"Bounce",
.5,
false
)
alert.Visible = false
wait(3)
script.Parent.Parent.Alerts.Visible = false
end
MarketService.PromptPurchaseFinished:Connect(function(player, assetId, isPurchased)
if isPurchased == true then
script.Parent.Parent.Alerts.TextBox.Text = "Successfully purchased!"
script.Parent.Parent.Alerts.Visible = true
script.Parent.Parent.Alerts:TweenPosition(
UDim2.new(0.06,0,0.738,0),
"In",
"Bounce",
.5,
false
)
wait(3)
script.Parent.Parent.Alerts:TweenPosition(
UDim2.new(-0.237, 0,0.738, 0 ),
"Out",
"Bounce",
.5,
false
)
wait(3)
script.Parent.Parent.Alerts.Visible = false
else
script.Parent.Parent.Alerts.TextBox.Text = "Failed to buy item"
script.Parent.Parent.Alerts.Visible = true
script.Parent.Parent.Alerts:TweenPosition(
UDim2.new(0.06,0,0.738,0),
"In",
"Bounce",
.5,
false
)
wait(3)
script.Parent.Parent.Alerts:TweenPosition(
UDim2.new(-0.237, 0,0.738, 0 ),
"Out",
"Bounce",
.5,
false
)
wait(3)
script.Parent.Parent.Alerts.Visible = false
end
end)
end)
If anyone could find me a way to fix this, so it loops perfectly everytime - I will be very thankful because I have no clue on how to solve this.