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

My picture won't show up. Why is this happening?

Again, I am on the same game I'm working on, and I'm working on the same script, and I came to another stump. Now, my picture won't show up when I click the play button. Here's the script code:

local DBO = script.Parent
local PB = script.Parent.PlayButton
local BG = script.Parent.Background
local Dragon = script.Parent.Background.DBOWallpaper
function onClick(MouseButton1Click)
		for i = 0, 1, 0.1 do
			PB.Transparency = i
			wait()
	end
end
script.Parent.PlayButton.MouseButton1Click:connect(onClick)

Dragon.ImageTransparency = 1
wait(0.1)
for i = 1, 0, 0.1 do
	Dragon.ImageTranparency = i
	wait()
end

1 answer

✓ Accepted answer

You have to actually put the code inside the onClick function.

Your MouseButton1Click event is tied to the onClick function. So whenever the event fires, the function is called.

This means any code you want to run when the event fires must be inside the onClick function, otherwise you won't get the results you want.

Move lines 13 - 18 inside the function.

local DBO = script.Parent
local PB = script.Parent.PlayButton
local BG = script.Parent.Background
local Dragon = script.Parent.Background.DBOWallpaper

Dragon.ImageTransparency = 1

function onClick()
	for i = 0, 1, 0.1 do
		PB.Transparency = i
    	Dragon.ImageTranparency = i
		wait()
	end
end

script.Parent.PlayButton.MouseButton1Click:connect(onClick)

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