How to Make a working Stereo and that pops up an Song ID Input?

Hello Developers! This topic is directly targetted for scripters! I am having some issues right now!

I am trying to make my stereo a WORKING one so when the person has a gamepass they can set a song by an ID and if they don’t have it, it will prompt them to buy the gamepass and then they can play on it after a re-join.

I tried Experimenting myself, tried searching YouTube and DevForums. Nothing was working/found

Another issue is that I have MUSIC AREAS. Basically if you are in Area 1, it will play a song. If you go to Area 2, it will play another song. I want to make Area 2 play the songs given on the stereo.

Any help please? Thanks!

Kieran
Akridiki

Just a little clarification. You said that u wanted to play a song on the stereo and the I’d of the song will be decided by the player. So what do u mean by stating that the song changes when the player goes to area 2? Will the player input another new I’d?

Okay so. Area 1 is set to just 1 THING. (Unchangeable). Area 2 is CHANGEABLE by people buying the gamepass and inputs an ID in a GUI.

Run an if statement that will check if the player has your game pass by using MarketPlace:UserOwnsGamePassAsync(player.UserId, 000000). If so, then clone a tool in their backpack. Else, use MarketplaceService:PromptGamePassPurchase(player, 000000) which will ask the player if they want to buy the gamepass

1 Like

I guess this is the code you want. It’s for a ClickDetector’s MouseClick function.
(The script must be inside something which parent has a ClickDetector in it, like a Part)

It works for me, i don’t know if it works for you.

    script.Parent.ClickDetector.MouseClick:Connect(function(player)
	local id = 8256828 --gamepass id goes here
	local pl = player --set this to the player variable before using!
	local mserv = game:GetService("MarketplaceService")
	
	if mserv:UserOwnsGamePassAsync(pl.UserId, id) then
		--has gamepass
	else
		--doesnt have gamepass, prompt purchase
		mserv:PromptGamePassPurchase(pl, id)
	end
end)

Where do I input the script in?

1 Like

Inside a BasePart, also called Part, for example. Then just add a ClickDetector inside that part.

Do you mean the stereo model? Also does this work in a group not just 1 part?

ClickDetectors must be inside a clickable thing, like a part.
Models aren’t clickable as they dont have a part to click.
Assuming you want it to be clickable anywhere, make an invisible part without collision, anchored, with the size of the stereo model.

1 Like

Late re-reply! It also works on models now! Haven’t noticed.

1 Like

Just put a clickdetector inside a model or part. It will work.

1 Like

Alright so I had to revoke the solution badge. Now, the problem is. How does it open the frame? Like when the person clicks the stereo IF THEY HAVE A GAMEPASS, A frame will appear.

Hello, came back to remind you it’s now done

1 Like