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.
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.
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.
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.
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.