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

How to make a music play button only for a gamepass?

Asked by
5y5sy 0
3 years ago

I already tried to make this but its not working.

local Music1 = script.Parent.Music1
local Music2 = script.Parent.Music2
local Music3 = script.Parent.Music3
local Music4 = script.Parent.Music4
local Music5 = script.Parent.Music5
local GamepassMusic = script.Parent.GamepassMusic
local id = 21386982
local stop = script.Parent.Stop
local music = script.Parent.FreeMusic


Music1.MouseButton1Down:connect(function()
    music.SoundId = 'rbxassetid://6770538572'
    music:Play()
end) 

Music2.MouseButton1Down:connect(function()
    music.SoundId = 'rbxassetid://2446563125'
    music:Play()
end)

Music3.MouseButton1Down:connect(function()
    music.SoundId = 'rbxassetid://4449307684'
    music:Play()
end)

Music4.MouseButton1Down:connect(function()
    music.SoundId = 'rbxassetid://695084056'
    music:Play()
end)

Music5.MouseButton1Down:connect(function()
    music.SoundId = 'rbxassetid://1361723321'
    music:Play()
end)

game.Players.PlayerAdded:Connect(function(player)
GamepassMusic.MouseButton1Down:connect(function()

        if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, id) then
music.SoundId = 'rbxassetid://3559665809'
    music:Play()
        end
    end)

end)

stop.MouseButton1Click:connect(function()
    music:Stop()
end)

Script type is LocalScript.

I can't find any errors in output. (Same when button clicked)

Also in first place i think that this is not gonna work.

Answer this question