Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a image change again after being pressed?

local CanClick = true
script.Parent.MouseButton1Click:connect(function()
if not CanClick then return end
  CanClick = false
workspace.Click:Play() 
wait(.2)
script.Parent.Parent.Parent.MusicPlayerReview.PlayReview.Image = "rbxassetid://293466205"
  CanClick = true
end)

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

2 answers

✓ Accepted answer

You could try something like:

local image = game.Workspace.ImagePart.DECAL -- change the variable to what you need
local button = script.Parent -- the variable selecting the click detector

function Clicked() -- this is only an example so you don't have to copy it exactly
	if image.Texture == "http://www.roblox.com/asset/?id=" then -- change the id to the default image
		wait(0.05) -- optional
		image.Texture = "http://www.roblox.com/asset/?id=" -- insert the 2nd image id here
	else
		wait(0.05) -- again, optional
		image.Texture = "http://www.roblox.com/asset/?id=" -- insert the default image id here
	end
end

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

2 comments

0

Had to change it up a bit, but it works. Thanks!

0

your welcome! I'm happy it worked!!

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

1 comment

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

This discussion is preserved as it was. New answers, comments, and votes are closed.