How would you be able to filter the word "Place" in a random game generator?

Hello (sorry this is a repost, i didnt have answers before)
I was curious how you would be able to filter out key words in my random game generator because a lot of the games have the word “place” in it, which is something like BlueClothesPerson's Place. How would I be able to find the word “place” any where in the text, and if it sees that word, it would try finding a new experience.

Current Script
local TeleportService = game:GetService("TeleportService")
local MarketplaceService = game:GetService("MarketplaceService")

local GetInfo = function(id)
	local PlaceID = id

	local thumbnail = "https://assetgame.roblox.com/Game/Tools/ThumbnailAsset.ashx?aid="..PlaceID .."&fmt=png&wd=420&ht=420"
	local surfacegui = script.Parent.Parent.Parent.SurfaceGui
	local Info = MarketplaceService:GetProductInfo(PlaceID,Enum.InfoType.Asset)
	local CreationDate = MarketplaceService:GetProductInfo(PlaceID)

	if Info.AssetTypeId == 9 then
		surfacegui.Thumbnail.Image = thumbnail
		surfacegui.PlaceName.Text = Info.Name
		surfacegui.CreationDate.Text = Info.Created
		surfacegui.LastUpdated.Text = Info.Updated
		surfacegui.Visits.Text = Info.Description
		return PlaceID
	end
end

local function GetRandomPlace()
	local rnger = math.random(100000, 2147483647) -- you CAN'T go any higher than this or it won't work
	local success, PlaceId = pcall(function()
		return GetInfo(rnger)
	end)

	if success and PlaceId then
		script.Parent.MouseClick:Connect(function(player)
			TeleportService:Teleport(PlaceId, player)
		end)
	else
		GetRandomPlace()
	end
end

while task.wait(10) do
	GetRandomPlace()
end
1 Like
1 Like

I didn’t quiet understand what you meant by this before, and it doesn’t seem to work:

give me a second im rewriting the script to work because its hard for me to correct the way u coded

no idea if this will work

local TeleportService = game:GetService("TeleportService")
local MarketplaceService = game:GetService("MarketplaceService")

local GetInfo = function(id)
	local thumbnail = "https://assetgame.roblox.com/Game/Tools/ThumbnailAsset.ashx?aid=".. id .."&fmt=png&wd=420&ht=420"
	local Info = MarketplaceService:GetProductInfo(id,Enum.InfoType.Asset)

	if Info.AssetTypeId == 9 then
		return {
			Name = Info.Name,
			Created = Info.Created,
			Updated = Info.Updated,
			Description = Info.Description,
			Thumbnail = thumbnail,
		}
	end
end

local IgnoredPlaceIds = {}
local function GRP()
	-- Generates a Random Place
	local RandomPlaceGenerator = math.random(100000, 2147483647)
	
	-- Checks if the player has recieved this place before OR contains Place in it
	if table.find(IgnoredPlaceIds, RandomPlaceGenerator) then
		GRP()
		return
	end
	
	-- This Line Make its so you cant get the same place your recieved before.
	table.insert(IgnoredPlaceIds, RandomPlaceGenerator)
	
	local success, errormessage = pcall(function()
		-- Recieves Information Needed
		local RecieveInformation = GetInfo(RandomPlaceGenerator)

		-- Fills out returned information
		local SurfaceGUI = script.Parent.Parent.Parent.SurfaceGui
		SurfaceGUI.Thumbnail.Image = RecieveInformation.Thumbnail
		SurfaceGUI.PlaceName.Text = RecieveInformation.Name
		SurfaceGUI.CreationDate.Text = RecieveInformation.Created
		SurfaceGUI.LastUpdated.Text = RecieveInformation.Updated
		SurfaceGUI.Visits.Text = RecieveInformation.Description
	end)
	if not success then
		warn(errormessage)
		GRP()
		return
	else
		script.Parent.MouseClick:Connect(function(player)
			TeleportService:Teleport(RandomPlaceGenerator, player)
		end)
	end
	
	
end

while task.wait(10) do
	GRP()
end

It still displays all experiences with “Place” in the name, but this is an improvement from the previous script. (Reason I want the word “Place” to be ignored and find a new game is because starter games have the word Place in it, which is pretty boring when 99% (or more) have the same thing and it is simply a starter place.)

do you want to remove the word place from the text, or detect if the word place is in the text?

Detect if the word Place is in the text, and if it is, try to find a new random game

o wait i forgot to add that part

SORRY, old one was wrong. Try this:

Try this:

local TeleportService = game:GetService("TeleportService")
local MarketplaceService = game:GetService("MarketplaceService")

local GetInfo = function(id)
	local PlaceID = id

	local thumbnail = "https://assetgame.roblox.com/Game/Tools/ThumbnailAsset.ashx?aid="..PlaceID .."&fmt=png&wd=420&ht=420"
	local surfacegui = script.Parent.Parent.Parent.SurfaceGui
	local Info = MarketplaceService:GetProductInfo(PlaceID,Enum.InfoType.Asset)
	local CreationDate = MarketplaceService:GetProductInfo(PlaceID)

	if Info.AssetTypeId == 9 then
		surfacegui.Thumbnail.Image = thumbnail
		surfacegui.PlaceName.Text = Info.Name
		surfacegui.CreationDate.Text = Info.Created
		surfacegui.LastUpdated.Text = Info.Updated
		surfacegui.Visits.Text = Info.Description
		return Info
	end
end

local function GetRandomPlace()
	local rnger = math.random(100000, 2147483647) -- you CAN'T go any higher than this or it won't work
	local success, result = pcall(function()
		return GetInfo(rnger)
	end)

        local PlaceId = rnger
        

	if success and PlaceId and not result.Name:match('Place') then
		script.Parent.MouseClick:Connect(function(player)
			TeleportService:Teleport(PlaceId, player)
		end)
	else
		GetRandomPlace()
	end
end

while task.wait(10) do
	GetRandomPlace()
end
1 Like
local TeleportService = game:GetService("TeleportService")
local MarketplaceService = game:GetService("MarketplaceService")

local GetInfo = function(id)
	local thumbnail = "https://assetgame.roblox.com/Game/Tools/ThumbnailAsset.ashx?aid=".. id .."&fmt=png&wd=420&ht=420"
	local Info = MarketplaceService:GetProductInfo(id,Enum.InfoType.Asset)

	if Info.AssetTypeId == 9 then
		return {
			Name = Info.Name,
			Created = Info.Created,
			Updated = Info.Updated,
			Description = Info.Description,
			Thumbnail = thumbnail,
		}
	end
end

local Check = function(id)
	local Info = MarketplaceService:GetProductInfo(id,Enum.InfoType.Asset)
	if string.find(Info.Name, "Place") then
		return false
	end
	return true
end

local IgnoredPlaceIds = {}
local function GRP()
	-- Generates a Random Place
	local RandomPlaceGenerator = math.random(100000, 2147483647)
	
	-- Checks for the word Place Before anything
	if not Check(RandomPlaceGenerator) then
		GRP()
		return
	end
	
	-- Checks if the player has recieved this place before OR contains Place in it
	if table.find(IgnoredPlaceIds, RandomPlaceGenerator) then
		GRP()
		return
	end
	
	-- This Line Make its so you cant get the same place your recieved before.
	table.insert(IgnoredPlaceIds, RandomPlaceGenerator)

	local success, errormessage = pcall(function()
		-- Recieves Information Needed
		local RecieveInformation = GetInfo(RandomPlaceGenerator)

		-- Fills out returned information
		local SurfaceGUI = script.Parent.Parent.Parent.SurfaceGui
		SurfaceGUI.Thumbnail.Image = RecieveInformation.Thumbnail
		SurfaceGUI.PlaceName.Text = RecieveInformation.Name
		SurfaceGUI.CreationDate.Text = RecieveInformation.Created
		SurfaceGUI.LastUpdated.Text = RecieveInformation.Updated
		SurfaceGUI.Visits.Text = RecieveInformation.Description
	end)
	if not success then
		warn(errormessage)
		GRP()
		return
	else
		script.Parent.MouseClick:Connect(function(player)
			TeleportService:Teleport(RandomPlaceGenerator, player)
		end)
	end


end

while task.wait(10) do
	GRP()
end
1 Like

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