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

How to make a image change again after being pressed?

Asked by 4 years ago
1local CanClick = true
2script.Parent.MouseButton1Click:connect(function()
3if not CanClick then return end
4  CanClick = false
5workspace.Click:Play()
6wait(.2)
7script.Parent.Parent.Parent.MusicPlayerReview.PlayReview.Image = "rbxassetid://293466205"
8  CanClick = true
9end)

How do you make it afterclicking, the player can change the image again and so on.

2 answers

Log in to vote
0
Answered by 4 years ago

You could try something like:

01local image = game.Workspace.ImagePart.DECAL -- change the variable to what you need
02local button = script.Parent -- the variable selecting the click detector
03 
04function Clicked() -- this is only an example so you don't have to copy it exactly
05    if image.Texture == "http://www.roblox.com/asset/?id=" then -- change the id to the default image
06        wait(0.05) -- optional
07        image.Texture = "http://www.roblox.com/asset/?id=" -- insert the 2nd image id here
08    else
09        wait(0.05) -- again, optional
10        image.Texture = "http://www.roblox.com/asset/?id=" -- insert the default image id here
11    end
12end
13 
14button.MouseClick:Connect(Clicked)

Basically, the script is creating a function ( which you could change to whatever you want ), and then when they click the part then it'll change the image using an if statement. The if statement is asking " is the image set to the default image?", if not then it'll change the image to the other decal but if the decal isn't set to the default image then it'll change it back to the default image.

( sorry if that didn't make sense, I tried my best explaining )

If this script doesn't work for your case or the script isn't exactly what you're looking for then comment it and I'll try to help more.

0
Had to change it up a bit, but it works. Thanks! TheBuliderMC 84 — 4y
0
your welcome! I'm happy it worked!! OreoCakelover 17 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

local Image = script.Parent.Parent.ImageLabel Image.MouseButton1Click:connect(function() Image.Image = 'rbxasset://IMAGEIDHERE' end)

0
doesn't work, I already have a MouseButton happening already. What I want is to have it where if the player clicks it again, it changes images. Vise Versa TheBuliderMC 84 — 4y

Answer this question