Okay so I have script that will make a random message show up on all the player's screens that are online at the time but the problem is if the user purchases this product 2 times in a row (it's a dev product) it will start to either not change the message text or it will make double of it. If you have any suggestions on how to work this please tell me. If you have any questions about it just ask me, I'll give you all the info you need.
P.S, the script works fine if I remove purchaser.Name but that kinda ruins the point of buying this product!
P.P.S, I can't provide any output because this has to be tested in a real roblox game, it's a dev product!
MarketplaceService = Game:GetService("MarketplaceService")
doublecoinsId = 21809336
shoutoutId = 21812513
local function shoutout(purchaser)
for i, player in ipairs(game.Players:GetChildren()) do
if player.Character and player.Character:FindFirstChild("Torso") then
end
local clone = game.Lighting.GoodCard:Clone()
local randomsayingnum = math.random(1, 4)
if randomsayingnum == 1 then
clone.Message.Text = purchaser.Name " is an MLG PRO, just sayin..."
elseif randomsayingnum == 2 then
clone.Message.Text = "Say in-chat HI " .. purchaser.Name .. " over and over again until your fingers are bleeding!"
elseif randomsayingnum == 3 then
clone.Message.Text = "Go send " ..purchaser.Name .. " a friend request because he da bozz!"
elseif randomsayingnum == 4 then
clone.Message.Text = "Shoutout to " ..purchaser.Name .. " for being so awesome and skilled, you should be more like him!"
end
clone.Parent = player.PlayerGui.MainScreen
wait()
end
wait(1)
end
MarketplaceService.ProcessReceipt = function(receiptInfo)
for i, player in ipairs(game.Players:GetChildren()) do
if player.userId == receiptInfo.PlayerId then
if receiptInfo.ProductId == doublecoinsId then
player.PlayerGui.MainScreen.PlayerValues.HasCoinBooster.Value = true
player.PlayerGui.MainScreen.Alert.Visible = true
player.PlayerGui.MainScreen.Alert.Message.Text = "Purchase successful, the coinbooster will last until you die or until the next game ends!"
elseif receiptInfo.ProductId == shoutoutId then
shoutout(player)
end
end
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
