Hello Developers,
I am having trouble with a script, and I can’t define why it isn’t working. Any ideas?
function ClickPlay()
local backframe = menu.BackgroundFrame
backframe.BackgroundTransparency = 0.1
wait(0.1)
backframe.BackgroundTransparency = 0.2
wait(0.1)
backframe.BackgroundTransparency = 0.3
wait(0.1)
backframe.BackgroundTransparency = 0.4
wait(0.1)
backframe.BackgroundTransparency = 0.5
wait(0.1)
backframe.BackgroundTransparency = 0.6
wait(0.1)
backframe.BackgroundTransparency = 0.7
wait(0.1)
backframe.BackgroundTransparency = 0.8
wait(0.1)
backframe.BackgroundTransparency = 0.9
wait(0.1)
backframe.BackgroundTransparency = 1
wait(0.1)
play.MouseButton1Click(ClickPlay)
(I defined variables earlier in the script.)
Thanks in advance for any help
function ClickPlay()
local backframe = menu.BackgroundFrame
backframe.BackgroundTransparency = 0.1
wait(0.1)
backframe.BackgroundTransparency = 0.2
wait(0.1)
backframe.BackgroundTransparency = 0.3
wait(0.1)
backframe.BackgroundTransparency = 0.4
wait(0.1)
backframe.BackgroundTransparency = 0.5
wait(0.1)
backframe.BackgroundTransparency = 0.6
wait(0.1)
backframe.BackgroundTransparency = 0.7
wait(0.1)
backframe.BackgroundTransparency = 0.8
wait(0.1)
backframe.BackgroundTransparency = 0.9
wait(0.1)
backframe.BackgroundTransparency = 1
wait(0.1)
end
play.MouseButton1Click:Connect(ClickPlay)
Just missing an end statement.
2 Likes
function ClickPlay()
local backframe = menu.BackgroundFrame
repeat
task.wait(0.1)
backframe.BackgroundTransparency += 0.1
until backframe.BackgroundTransparency >= 1
end
play.MouseButton1Click:Connect(ClickPlay)
You may prefer this though.
1 Like
Ahh, did I forget an “end”. Simple mistakes. Thanks for helping and I will test it now.
Also missing :Connect()
I’ve added those in now. They’re required to connect functions to events.
1 Like
Umm, problem: When I click the ‘play’ button, nothing happens.
I’ve edited both, they were missing :Connect() as stated above.
1 Like
Still not working. Here is the full script if you need it. (bit we are using is at bottom)
local menu = script.Parent
local loading = menu.LoadingText
local play = menu.Play
local plrs = game:GetService("Players")
local plr = plrs.LocalPlayer
play.Visible = false
loading.Text = "Waiting for server."
wait(0.5)
loading.Text = "Waiting for server.."
wait(0.5)
loading.Text = "Waiting for server..."
wait(0.5)
loading.Text = "Waiting for server."
wait(0.5)
loading.Text = "Waiting for server.."
wait(0.5)
loading.Text = "Waiting for server..."
wait(0.5)
loading.Text = "Waiting for server."
wait(2)
loading.Text = "Loading Assets: 1/30"
wait(0.1)
loading.Text = "Loading Assets: 2/30"
wait(0.1)
loading.Text = "Loading Assets: 3/30"
wait(0.1)
loading.Text = "Loading Assets: 4/30"
wait(0.1)
loading.Text = "Loading Assets: 5/30"
wait(0.1)
loading.Text = "Loading Assets: 6/30"
wait(0.1)
loading.Text = "Loading Assets: 7/30"
wait(0.1)
loading.Text = "Loading Assets: 8/30"
wait(0.1)
loading.Text = "Loading Assets: 9/30"
wait(0.1)
loading.Text = "Loading Assets: 10/30"
wait(0.1)
loading.Text = "Loading Assets: 11/30"
wait(0.1)
loading.Text = "Loading Assets: 12/30"
wait(0.1)
loading.Text = "Loading Assets: 13/30"
wait(0.1)
loading.Text = "Loading Assets: 14/30"
wait(0.1)
loading.Text = "Loading Assets: 15/30"
wait(5)
loading.Text = "Loading Assets: 17/30"
wait(1)
loading.Text = "Loading Assets: 18/30"
wait(0.5)
loading.Text = "Loading Assets: 19/30"
wait(0.5)
loading.Text = "Loading Assets: 20/30"
wait(0.5)
loading.Text = "Loading Assets: 21/30"
wait(0.5)
loading.Text = "Loading Assets: 22/30"
wait(0.5)
loading.Text = "Loading Assets: 23/30"
wait(0.5)
loading.Text = "Loading Assets: 24/30"
wait(0.5)
loading.Text = "Loading Assets: 25/30"
wait(0.5)
loading.Text = "Loading Assets: 26/30"
wait(0.5)
loading.Text = "Loading Assets: 27/30"
wait(0.5)
loading.Text = "Loading Assets: 28/30"
wait(0.5)
loading.Text = "Loading Assets: 29/30"
wait(3)
loading.Text = "Loading Assets: 30/30"
wait(0.5)
loading.Text = "Done!"
wait(1)
loading.Visible = false
play.Visible = true
function ClickPlay()
local backframe = menu.BackgroundFrame
repeat
task.wait(0.1)
backframe.BackgroundTransparency += 0.1
until backframe.BackgroundTransparency >= 1
end
play.MouseButton1Click:Connect(ClickPlay)
What’s the error, the code I provided I tested my end & it worked.
1 Like
Maybe you just need to change it to LocalScript as GUI things requires LocalScripts
1 Like
Uhh, got this in output
“MouseButton1Click is not a valid member of Frame”
Yeah, it needs to be a local script, make sure the variable declarations are also pointing to the correct UI elements.
1 Like
Thanks for your suggestion but it is already in a LocalScript.
https://developer.roblox.com/en-us/api-reference/class/GuiButton
MouseButton1Click is an event for GuiButtons only (textbuttons, imagebuttons), it can’t be used in conjunction with a frame.
1 Like
That means “local play = menu.Play
” is a frame and not a button, change it to a button.
1 Like
OH! Simple error. It was pointing to a frame with a button as the frame’s child. I knew already that it doesn’t work on frames but thanks, there was a button in the frame called PlayButton. My bad!
All good, everything should work now.
1 Like