How To Find The Name Of This?

Hi all. I’m trying to make a crystal GUI which works alongside Region3 to determine whether someone has found a crystal or not. I’ve got the region3 part down pat, but I have these “Mystery” crystal images which act as placeholders for the crystal images which will appear when they get found (using region3).

Now, when a player “finds” a crystal by entering that crystals region3 area, I want the “Mystery” crystal image’s visibility to turn to false (or be deleted). Then I’d like this vacant space where the mystery image used to be to be filled with the image of the crystal, by making the crystal image visible.
Screenshot (584)

“Crystal” is the mystery image - “Crystal found” is the real image of the crystal…

The thing is, I have many of these different images, and I don’t know how to get the “mystery” image that is connected to the certain crystal image, and delete it.
Help would be greatly appreciated, thankyou.

PS: Apologies for the long post.


Why not instead compare (if part.Parent == Player.Character then)?

Or try avoid the use of “Dot”, instead try :FindFirstChild() in local variables to make sure the localscript is reading the script correctly.

1 Like

assign each crystal image when you make them a tag with collectionservice, or just use roblox’s attribute system, either way works

1 Like

Yeah, its reading the script correctly. And in answer to your question, that was the only way I knew how to do it.

Do you know how I can make the script find the name of those mystery images though?

1 Like

How would this help? I’m trying to make the mystery images invisible or deleted.

assign each image a tag that corresponds with the associated crystal, and when the crystal is found loop through every image until you find a matching tag, then remove it and replace it with the other one

1 Like

May I see the tree of where the first screenshot is?

1 Like

If this is what you mean by tree, yes :
(Ignore the weird names lol, placeholders for now).

It goes on for a bit longer than this though.

-- Script form
game.Startergui.FoundGUI.CrystalFrame.Scroll.(All the crystal mystery images + actual images).

@Jozeni00 does this help?

1 Like

Yes that helps, thank you.

I found the problem,

To find the mystery frame, use if string.match(frame.Name, v.Name) then and turn it invisible or destroy it.

It really depends, if v.Name does NOT have “Found” in it, you should be fine so it catches the name only.

1 Like

V.Name does have “Found” in it, unfortunately.

Since it does have “Found”, try string.sub().

if string.match(frame.Name, string.sub(v.Name, 1, (string.len(v.Name) - 5))) then and destroy/ make it invisible.

The sub will only catch every letter before “Found” and checks if it matches with the frame.

1 Like

Where would this go in my script to make sure that it works smoothly and correctly? Where it says?

-- Turn visible off for mystery
1 Like

Also, sorry for being naive but what would I put as the variable for the “frame” part of the code you provided?

1 Like

Yes, because it needs to be destroyed.

Rewriting the string.sub thing:
if string.match(frame.Name, string.sub(v.Name, 1, (string.len(v.Name) - 5))) and not string.match(frame.Name, “Found”) then

“not” to check if its not the “Found” frame.

This will go under where you made the “Found” visible.

1 Like

That’s true. I totally forgot about that.

In that case. You will need to make variable names.

local mystName = string.sub(v.Name, 1, (string.len(v.Name) - 5))


mystName is v.Name, but subbed without “Found”

Scroll is the same thing how you used Scrill[v.Name]

1 Like

So do I still need the other line of code provided before?

Nevermind, I realised that I do lol - but this doesn’t fix the error line thingies.

I’m still learning scripting lol, so that should explain a bit…

1 Like
if found == true then 
			--Make images visible
			if script.Parent.FoundClothing.Clothingframe.Scroll[v.Name].Visible == false then
			 script.Parent.FoundClothing.Clothingframe.Scroll[v.Name].Visible = true
				 local mystName = string.sub(v.Name, 1, (string.len(v.Name) - 5))
script.Parent.FoundClothing.Clothingframe.Scroll[mystName].Visible = false
--Turn visible off for mystery
1 Like