Help with checking if text has 'Place' in the name

Hi developer!

I have a script that is supposed to detect whether a game is a starter place or not by checking if the game’s name has the word ‘Place’ anywhere in it. The game name text label collects the name of the game that’s selected just fine, its just the detector that simply can’t find ‘Place’ in the title. Any help is appreciated!

Here’s the script:

local text = script.Parent
local isStarter = script.Parent.isStarter
local url = text.Parent.Parent.URLBox
local name = script.Parent.Parent.gamename

local msService = game:GetService('MarketplaceService')

local function check2()
	local gameName = msService:GetProductInfo(url.Text).Name
	if url.Text:match('Place') then
		script.Parent.isStarter.Value = true
	else
		script.Parent.isStarter.Value = false
	end
end

local function check()
	if isStarter == true then
		text.TextColor3 = Color3.fromRGB(117, 255, 96)
		text.Text = 'STARTING PLACE: TRUE'
	elseif isStarter == false then
		text.TextColor3 = Color3.fromRGB(255, 70, 73)
		text.Text = 'STARTING PLACE: FALSE'
	end
end



name.Changed:Connect(check)
name.Changed:Connect(check2)

And yes, the functions are cluttered and I could probably fix that, I just need help with the url.Text:match() function.

1 Like

if string.gmatch(“Place”, url.Text) then
//CODEHERE
end

Maybe try this instead?

1 Like

also you could get rid of the “script.Parent.IsStarter.Value = VALUE” unless you use it somewhere else, if you don’t then;

if check2(gameName) then
end

and replace the script.Parent.isStarter.Value = true/false with return true or return false if this makes sense.

1 Like

Hi! isStarter is a boolean value used by the detector text label to change its text respectively. It can obviously be voided, though.

1 Like

Hey, yeah I do see that, but what I’m saying it if that value is not used anywhere else in other scripts, you could do as I suggested, saves having a Value that’s edited by the same script when you could just called a function and wait to see what it returns.

Also, please check about the string.gmatch that I replied with to see if that fixes your original issue.

1 Like

I’m currently working on incorporating your string.gmatch. I’ll keep you updated on if this works!

1 Like

Alrighty, feel free to DM me or simply reply to this thread if any extra help may be needed.

1 Like

Right, so I kind of incorporated your method and instead wrote this:

local text = script.Parent
local url = text.Parent.Parent.URLBox
local name = script.Parent.Parent.gamename

local function check()
if string.gmatch("Place", name.Text) then
		text.TextColor3 = Color3.fromRGB(111, 255, 123) --111, 255, 123
		text.Text = 'STARTING PLACE: TRUE.'
	else
		text.TextColor3 = Color3.fromRGB(255, 70, 73) --255, 70, 73
		text.Text = 'STARTING PLACE: FALSE'
	end
end

name.Changed:Connect(check)

The unfortunate part is I receive the same result and I’m not entirely sure what I’m doing wrong.

1 Like

Give me a second, I’m going to change your code a little bit and send you something to try. Hold on.

1 Like

Sounds good. If this helps, it’s a server script and not local, if that would change anything.

Actually, can you show me what name.Text contains? the entire string

name.Text is utilising MarketplaceService to collect the game name provided from the game ID found in url.Text, so it’s default string is always a placeholder.

Its current string is ‘Game Name’

Hm, okay can you try changing name.Changed:Connect(check) to name:GetPropertyChangedSignal("Text"):Connect(check) ?

Seems to mark any change as a starting place

What do you mean? Sorry, not understanding the wording

https://gyazo.com/3e71a4aa73efdd361e1d1052fe911e99

Can you try manually changing the Text Value to different things, with and without the word “Place” in it, does it update accordingly as it’s suppose to with true/false

Obviously Server Side, since that’s how you detect it.

Doesn’t look like it reacts to manual changing

if string.find(name.Text, "Place") then
    print(name.Text, "has the word Place in it!")
end