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

For some reason it keeps saying Mousebutton1 is not a valid member of image label Any Help?

For some reason it keeps saying "Mousebutton1 is not a valid member of image label". No matter what i do it wont fix it. Any help?

local MarketplaceService = game:GetService("MarketplaceService")

 Shop = script.Parent.Shop
local speedcoilgamepass = Shop.Gamepassitems.ScrollingFrame.ImageContainer1.SpeedCoilgamepass
local Open = Shop.Parent.Open

local player = game.Players.LocalPlayer

local speedcoilgamepassID = 29031429

speedcoilgamepass.MouseButtonDown1:Connect(function()
	local success, message = pcall(function()
		haspass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, speedcoilgamepassID)
	end)
	
	if haspass then
		print("player already has the gamepass")
	else
		MarketplaceService:PromptGamePassPurchase(player, speedcoilgamepassID)
	end
end)

Open.MouseButton1Down:Connect(function()
	Shop.Visible=not Shop.Visible
end)

2 answers

Use an ImageButton instead of an ImageLabel. Its basically the same, but has the MouseButton1Down event you are looking for

If you don't want to use an ImageButton, your other option is to listen to the player's MouseClick with UserInputService, and check to see if their mouse is hovering above the Open ImageLabel manually.

6 comments

0

Yea but now it says "MouseButtonDown1 is not a valid member of ImageButton"

1

You wrote it wrong. "MouseButtonDown1" -> "MouseButton1Click"

0

My bad

0

Now it says "Mousebutton1Click is not a valid member of image label".

0

You're supposed to use an ImageButton instead of an ImageLabel

0

nvm i fixed it

Basically all you need to do is to make the ImageLabel a ImageButton, I also corrected some things in your script. Have a nice day!

local MarketplaceService = game:GetService("MarketplaceService")

Shop = script.Parent.Shop
local speedcoilgamepass = Shop.Gamepassitems.ScrollingFrame.ImageContainer1.SpeedCoilgamepass
local Open = Shop.Parent.Open

local player = game.Players.LocalPlayer

local speedcoilgamepassID = 29031429
local haspass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, speedcoilgamepassID)

speedcoilgamepass.MouseButton1Click:Connect(function()
	local success, message = pcall(function()
		 haspass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, speedcoilgamepassID)
	end)

	if haspass then
		print("player already has the gamepass")
	else
		MarketplaceService:PromptGamePassPurchase(player, speedcoilgamepassID)
	end
end)

Open.MouseButton1Click:Connect(function()
	Shop.Visible = not Shop.Visible
end)


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