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

It Always says "MouseButtonClick1" is not a valid member of ImageLabel what do i do?

Asked by
sproxa 7
5 years ago
Edited 5 years ago

im trying to make a close button for a gui but for someone uknown reason it always says "MouseButton1Click" is not a valid member of ImageLabel here is the script

script.Parent.MouseButton1Click:connect(function() game.StarterGui.ScreenGui.Frame.Visible = false end)

Can someone please help me ?

0
You're using an ImageLabel rather than an ImageButton. CorruptScript 86 — 5y
0
ImageLabels don't have the MouseButton1Click or other mouse events. However, ImageButtoms do cringe_worthey 97 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

There are a few issues here.

1) You should be using a TextButton instead of a TextLabel. TextLabels are meant to just display text, while TextButtons are meant to be clicked to perform an action.

2) :connect() is deprecated. You should use :Connect() instead. The script should look like this:

3) You are attempting to change the frame that is in the StarterGui. The way you are doing it, it will change the Gui when a player is spawned in again. However, when a player joins a game the StarterGui is cloned into PlayerGui. This script should be a LocalScript so you can do a nifty little thing called LocalPlayer, which you can use to immediately find the player that pressed the button.

The script should look like this:

script.Parent.MouseButton1Click:Connect(function()
    game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = false
end)

You need to change your TextLabel into a TextButton, put a LocalScript in it, then paste the script above.

If this answer helped you, please ACCEPT and UPVOTE it! Thank you!

0
Thanks it works now :D sproxa 7 — 5y
0
Please accept and upvote my answer! SchonATL 15 — 5y
0
No.^ stop asking for reputation User#19524 175 — 5y
0
No.^ stop having more rep than me SchonATL 15 — 5y
Ad

Answer this question