Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How to make this work after clicking a model and gets removed after clicking another model? (N/A)

Asked by 9 years ago

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:

01local song1 = game.Workspace.BoxCD.song1
02local disc1 = game.Workspace.PlainDisc2.Decal
03touch = false
04inserted = false
05 
06function onClicked(clicker)
07    if not touch then
08        touch = true
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 = UDim2.new(0, 500, 0, 25)
13        image.Size = UDim2.new(0, 450, 0, 500)
14        image.Image = "rbxassetid://238387775"
15        insert.Position = UDim2.new(0, 830, 0, 485)
View all 29 lines...

Script for Song2:

01local song2 = game.Workspace.BoxCD.song2
02local disc2 = game.Workspace.PlainDisc2.Decal
03touch = false
04inserted = false
05 
06function onClicked(clicker)
07    if not touch then
08        touch = true
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 = UDim2.new(0, 500, 0, 25)
13        image.Size = UDim2.new(0, 450, 0, 500)
14        image.Image = "rbxassetid://98698696"
15        insert.Position = UDim2.new(0, 830, 0, 485)
View all 29 lines...

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.

0
I'm not sure that anyone understands what you are asking. Your explanation of what is happening is not clear. AZDev 590 — 9y
0
What do you mean? That is very hard to understand, (your explanation) TheHospitalDev 1134 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

Well you have to make a button and once uou have done that you have to go to "Local Script" and add the click function to make it work!

Ad

Answer this question