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

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

Asked by 7 years ago

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

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

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

Answer this question