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

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

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 ?

2 comments

0

You're using an ImageLabel rather than an ImageButton.

0

ImageLabels don't have the MouseButton1Click or other mouse events. However, ImageButtoms do

1 answer

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!

4 comments

0

Thanks it works now :D

0

Please accept and upvote my answer!

0

No.^ stop asking for reputation

0

No.^ stop having more rep than me

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