Hello, I’ve been working on a project one day and my script fails out of nowhere. No errors, warnings, etc.
Part of the script suspected to be not working:
game.ReplicatedStorage.GetPayouts.OnServerEvent:Connect(function(plr)
local HttpService = game:GetService("HttpService")
local err = plr.PlayerGui.GameUI.GetPayoutsFrame.Error
local gamePassId = plr.PlayerGui.GameUI.GetPayoutsFrame.GamepassId.Text
-- Fetch the game pass details from the API
local detailsundecoded = HttpService:GetAsync("https://wave-graceful-hyacinth.glitch.me/?link=https://apis.roblox.com/game-passes/v1/game-passes/" .. gamePassId .. "/product-info")
-- Check if the game pass was not found
if detailsundecoded == '"gamepass not found"' then
err.Text = "Gamepass not found."
return
end
-- Attempt to decode the JSON response
local success, details = pcall(function()
return HttpService:JSONDecode(detailsundecoded)
end)
if not success then
err.Text = "Failed to decode JSON data."
return
end
-- Debugging: Print details to the output for inspection
print("Decoded JSON Details: ", details)
-- Validate the Creator field
if not details["Creator"] then
err.Text = "Creator field is missing in gamepass details."
return
end
local creatorName = details["Creator"]["Name"]
if not creatorName then
err.Text = "Creator Name is missing in gamepass details."
return
end
-- Check if the Creator's Name matches the player's Name
if creatorName == plr.Name then
local priceInRobux = details["PriceInRobux"]
local userRobux = playersrobux[plr.Name] or 0
-- Ensure the player has enough Robux
if priceInRobux <= userRobux then
-- Check if the price is one of the allowed values
local validPrices = {5, 10, 25, 50, 100, 500, 1000}
local isValidPrice = false
for _, validPrice in ipairs(validPrices) do
if priceInRobux == validPrice then
isValidPrice = true
break
end
end
if isValidPrice then
table.insert(gamepassqueue, gamePassId)
playersrobux[plr.Name] = userRobux - priceInRobux
err.TextColor3 = Color3.new(0, 0.333333, 0)
err.Text = "Gamepass added to queue! Don't leave the game because it will remove it from queue!"
else
err.Text = "Gamepass price is not within the allowed values."
end
else
err.Text = "Gamepass value is more than player's Robux Earned value."
end
else
err.Text = "Gamepass isn't owned by user " .. plr.Name
end
end)
If you need the full code, please ask for it trought DMs or in replies.
Regards,
fiftyseven.