Yes but in client script if you changed the text of the box inside the client.
script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
game.ReplicatedStorage.Tutorial:FireServer(script.Parent, script.Parent.Text)
end)
And in the server script,
game.ReplicatedStorage.Tutorial.OnServerEvent:Connect(function(player, box, text)
box.Text = text
end)
I’m a bit confused about the server script. I know what text is for but what are player and box for?
You sent the location of the box and the server will equate the text of the box to written ID number in client. So the new text is now the product ID for the both server and client.
Let me know if it doesn’t work.
Then the ID
variable is missing or nil. You can debug this by calling
print(ID)
before you use pcall and see what it prints. This way you can keep track of what is going on.
Now it’s not returning an error, which is good, but now it still isn’t changing the image.
What is response here related for? Isn’t it purchaseInfo ?
game.Workspace.AdvertBoard.SurfaceGui.Frame.Template.Image = "rbxassetid://"..purchaseInfo.IconImageAssetId
Just figured it out, I put ID
instead of response.IconImageAssetId
.
But the image is still not changing actually.
0V_ex
(vex)
May 3, 2021, 9:13am
#17
You forgot to return the value that you fetched in the pcall function, lol.
local success, response = pcall(function()
return MarketplaceService:GetProductInfo(ID)
end)
If you don’t return the fetched value, response would be the error message if the execution wasn’t successful or nil.
You don’t need to use response here. It must be purchaseInfo .
game.Workspace.AdvertBoard.SurfaceGui.Frame.Template.Image = "rbxassetid://"..purchaseInfo.IconImageAssetId
I used ID
because the ID is the value of the assetId.
0V_ex
(vex)
May 3, 2021, 9:24am
#21
Sadly, purchaseInfo doesn’t return its Asset Icon ID. Please just re-check what it returns here: MarketplaceService.ProcessReceipt
You indeed have to fetch the ProductInfo from MarketPlaceService. @Wildcutepenguin , just try my solution out in case you missed it out.
You forgot to return the value that you fetched in the pcall function, lol.
local success, response = pcall(function()
return MarketplaceService:GetProductInfo(ID)
end)
If you don’t return the fetched value, response would be the error message if the execution wasn’t successful or nil.
1 Like
Yeah, my confused mind.
Don’t forget to add the RemoteEvent though.
Just so everyone is on the same page, this is what my script looks like. currently *
local MarketplaceService = game:GetService("MarketplaceService")
local GetProductInfo = MarketplaceService.GetProductInfo
local debounce = false
game.ReplicatedStorage.SendText.OnServerEvent:Connect(function(player, box, text)
box.Text = text
end)
MarketplaceService.ProcessReceipt = function(purchaseInfo)
local plr = game:GetService("Players"):GetPlayerByUserId(purchaseInfo.PlayerId)
if purchaseInfo.ProductId == 1167909680 and debounce == false then
debounce = true
print("24 HOUR ADVERT bought.")
local ID = tonumber(plr.PlayerGui.AdGui.Frame.TextBox.Text)
local success, response = pcall(function()
return MarketplaceService:GetProductInfo(ID)
end)
if success then
game.Workspace.AdvertBoard.SurfaceGui.Frame.Template.Image = "rbxassetid://"..ID
else
warn(response)
end
wait(1)
debounce = false
elseif purchaseInfo.ProductId == 1167909777 and debounce == false then
debounce = true
print("THREE DAY ADVERT bought.")
wait(1)
debounce = false
elseif purchaseInfo.ProductId == 1167909888 and debounce == false then
debounce = true
print("30 DAY ADVERT bought.")
wait(1)
debounce = false
end
return Enum.ProductPurchaseDecision.PurchaseGranted
end
This only works for decals, not thumbnails of clothing or games.
@ProBaturay @0V_ex @Brickman808
Sorry for the late response. Try this
local ID = tonumber(plr.PlayerGui.AdGui.Frame.TextBox.Text)
local asset
local success, response = pcall(function()
asset = MarketplaceService:GetProductInfo(ID)
end)
if success then
game.Workspace.AdvertBoard.SurfaceGui.Frame.Template.Image = asset.IconImageAssetId
else
warn(response)
end
That’s ok but the script still doesn’t work.
ProBaturay:
asset.IconImageAssetId
Instead
"rbxassetid://" .. asset.IconImageAssetId
Yes! We have a solution finally.
It only works on games, is there any way for it to work for clothing too?
1 Like
What do you mean by clothing? Are you trying to dress a body up?
No, I just want them to be able to advertise games, shirts and pants.