Textlabel doesn't change to wanted text

the error: attempt to concatenate nil with string
this script is to advertise player’s game by text but in line 24 it occurs the error
script:

local box = script.Parent
local gameImg = box.Parent:WaitForChild("GameImage")
local advertisebtn = box.Parent:WaitForChild("Advertise")
local mps = game:GetService("MarketplaceService")
local adtext = box.Parent.Parent:WaitForChild("AdvertisementText")
local plr = game.Players.LocalPlayer

productID = 1878843532

box.FocusLost:Connect(function(EP, ifl)
	if EP then
		local id = tonumber(box.Text)
		if id then
			local gameInfo = game:GetService("MarketplaceService"):GetProductInfo(id)
			if gameInfo then
				gameImg.Image = "rbxassetid://" .. gameInfo.IconImageAssetId
				box.Text = "Game Detected !"
				wait(1)
				box.Text = ""
				wait(0.1)
				advertisebtn.MouseButton1Click:Connect(function()
					local gameId = tonumber(box.Text)
					mps:PromptProductPurchase(game.Players.LocalPlayer, productID)
					adtext.Text = "Join"..gameInfo.Value .."Made By  ".. plr.Name
				end)
			end
		end
	end
end)

Add a tostring() around the part where you get the error.

1 Like

gives me table: numbers
i want the player’s game name so that they can advertise their game

I don’t know if I am right but try this
adtext.Text = "Join"..gameInfo.Name .."Made By ".. plr.Name

1 Like

you are right ! but i prefer tostring(gameInfo.Name) but thank you !

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.