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

A script that play a music in a game?

So I made a GUI and put this script in it.

local okbutton = script.Parent.TextButton

function onClicked(id)
	id = script.Parent.TextBox.Text
	local music1 = Instance.new("Sound")

	music1.Parent = game.Workspace

	music1.SoundId = "http://www.roblox.com/asset/?id="..id

	wait(1)
	music1:Play()
end

script.Parent.TextButton.MouseButton1Click:Connect(onClicked)

Well, it's not working. Can somebody help me fix this?

1 answer

I tested my script out and I found out that it works!

local okbutton = script.Parent.TextButton
okbutton.MouseButton1Click:Connect(function()
	local id = script.Parent.TextBox.Text
	local music1 = Instance.new("Sound")

	music1.Parent = game.Workspace

	music1.SoundId = "rbxassetid://"..id

	wait(1)
	music1:Play()
end)

3 comments

0

You just had to change your music1.SoundId to "rbxassetid://" instead of "http://www.roblox.com/asset/?id="

0

Hi there!

0

Yes it's working, but i want to make it like the music plays in the whole server using RemoteEvent. I accidentally posted this question 2 times can you check the script what i wrote here? I would be very grateful. https://scriptinghelpers.org/questions/124882/a-script-that-play-a-music-in-a-game

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