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

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

Asked by 1 year ago
Edited 1 year ago

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

Log in to vote
2
Answered by 1 year ago

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.

0
Yea but now it says "MouseButtonDown1 is not a valid member of ImageButton" clayman4589 0 — 1y
1
You wrote it wrong. "MouseButtonDown1" -> "MouseButton1Click" 9mze 193 — 1y
0
My bad virushunter9 943 — 1y
0
Now it says "Mousebutton1Click is not a valid member of image label". clayman4589 0 — 1y
View all comments (2 more)
0
You're supposed to use an ImageButton instead of an ImageLabel virushunter9 943 — 1y
0
nvm i fixed it clayman4589 0 — 1y
Ad
Log in to vote
0
Answered by 1 year ago

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)


Answer this question