How to make this work after clicking a model and gets removed after clicking another model? (N/A)
To clarify what I said in the Title. I made a script, which was fixed by M39 (thank you), and it worked. So, I then made another one for the second model. Well, when I clicked the model, it poped up the gui, which means it worked. But when I clicked a different one, I hit insert and all of the sudden the one I clicked before still showed up instead of it being removed after I clicked a different one. I want it where if I click something, and when I don't want that, I click a different one which will make the other gui that I clicked before destroyed or remove. This is the script for the first model and for the second model. They are the same, but I did it just in case for like details :D:
Script for Song1:
01 | local song 1 = game.Workspace.BoxCD.song 1 |
02 | local disc 1 = game.Workspace.PlainDisc 2. Decal |
06 | function onClicked(clicker) |
09 | local screen = Instance.new( "ScreenGui" , clicker.PlayerGui) |
10 | local image = Instance.new( "ImageLabel" , screen) |
11 | local insert = Instance.new( "ImageButton" , screen) |
12 | image.Position = UDim 2. new( 0 , 500 , 0 , 25 ) |
13 | image.Size = UDim 2. new( 0 , 450 , 0 , 500 ) |
15 | insert.Position = UDim 2. new( 0 , 830 , 0 , 485 ) |
16 | insert.Size = UDim 2. new( 0 , 120 , 0 , 40 ) |
19 | insert.MouseButton 1 Down:connect( function () |
29 | script.Parent.ClickDetector.MouseClick:connect(onClicked) |
Script for Song2:
01 | local song 2 = game.Workspace.BoxCD.song 2 |
02 | local disc 2 = game.Workspace.PlainDisc 2. Decal |
06 | function onClicked(clicker) |
09 | local screen = Instance.new( "ScreenGui" , clicker.PlayerGui) |
10 | local image = Instance.new( "ImageLabel" , screen) |
11 | local insert = Instance.new( "ImageButton" , screen) |
12 | image.Position = UDim 2. new( 0 , 500 , 0 , 25 ) |
13 | image.Size = UDim 2. new( 0 , 450 , 0 , 500 ) |
15 | insert.Position = UDim 2. new( 0 , 830 , 0 , 485 ) |
16 | insert.Size = UDim 2. new( 0 , 120 , 0 , 40 ) |
19 | insert.MouseButton 1 Down:connect( function () |
29 | script.Parent.ClickDetector.MouseClick:connect(onClicked) |
These are separate scripts for each model I put it. What happened is that when I click the first one, it pop ups, but let say they want to see the other ones, well, they click it and then they insert it. Well, after I clicked insert, it worked but the other gui that popped up before was still there and wasn't removed after I clicked a different one. I hope this one explained really good.