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

Log in to vote
0
Answered by 4 years ago

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.

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