Your problem is that you are trying to change the transparency, when the value you want to change is BackgroundTransparency. Additionally, your code is very inefficient; you can replace that long reduntant piece of code with a loop.
the best loop to use here is a for loop, because they take little effort to make and are most commonly used when you want a counting variable
function OnClicked()
local x = Instance.new("Frame")
x = script.Parent.Parent.ScreenGui
x.BackgroundColor3 = Color3.new(0,0,0)
x.Size = UDim2.new(1,0,1,0)
for i = 0, 1, .1 do
x.BackgroundTransparency = i
wait(0.2)
end
x:Destroy()
end
script.Parent.MouseButton1Down:connect(OnClicked)
The first parameter of a for loop is the variable you want to count, with the starting value. In this case, "i" is our counting variable, and we want it to start counting up from 0.
The second parameter is the goal you want to reach. The for loop will continuously run the given code until the counting variable reaches that goal.
The third parameter is the increment at which the counting variable counts at. The increment is added to the counting variable with each iteration of the for loop.
For more information on loops, you can search the roblox wiki here, or the scripting helpers glossary here.
3 comments
Wait, the frame needs to be clicked? or another button like a Text Button?
Another button but I fixed it
Ok