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

SoundId needs a string and not an object?

Asked by 6 years ago
local relaxid = "231311947"
function playmusic(id, replay)
    playing = true
    if game.Workspace:FindFirstChild("music") then
        game.Workspace:FindFirstChild("music"):Stop()
        game.Workspace:FindFirstChild("music"):Destroy()
    end
    local music = Instance.new("Sound", game.Workspace)
    music.Name = "music"
    music.SoundId = id
    if replay == true then
        music.Looped = true
    else
        music.Looped = false
    end
    music:Play()
end

playmusic(relaxid, true)

The problem with this script is that it says that music.SoundId needs to be a string, and that id is an object. How would i turn id into a string?

2 answers

Log in to vote
1
Answered by 6 years ago

Heres the problem I see. To use an sound Id, you will need the prefix rbxassetid:// before the song ID. So, your relaxid variable should be this.

local relaxid = 'rbxassetid://231311947'
Ad
Log in to vote
0
Answered by
commag 228 Moderation Voter
6 years ago

You need to change it to "rbxassetid://" then your Id number :)

Answer this question