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

Why is my custom music id always giving me a error when i use a custom ID?

Asked by
iuclds 720 Moderation Voter
4 years ago
Edited 4 years ago

k = Instance.new("Sound")

script.Parent.Enter.MouseButton1Click:Connect(function()
    if k.SoundId == "Shrek" then
        k.SoundId = "rbxassetid://".."2028376534" -- shrek national anthem
        k.Playing = true
    end
end)
script.Parent.Enter.MouseButton1Click:Connect(function()
    if k.SoundId == "Sans" then
        k.SoundId = "rbxassetid://".."2525122648" -- sans default dance
        k.Playing = true
    end
end)
script.Parent.Enter.MouseButton1Click:Connect(function()
    if k.SoundId == "AW MAN" then
        k.SoundId = "rbxassetid://".."1057637788" -- creepa, AW MAN. SO WE BACK IN THE MINE
        k.Playing = true
    end
end)

and i also tried

.
if k.SoundId == "rbxassetid://".."Shrek" then

It continuously fails to load sound ID

Failed to load sound rbxassetid://Sans: Unable to download sound data
0
are you trying to make it so people can type out the sound instead of writing the numbers and then the sound will play? Gameplayer365247v2 1055 — 4y
0
yeah gamer iuclds 720 — 4y
0
also give us the error so we know what we are working with Gameplayer365247v2 1055 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

If you use the "rbxassetid: //" then it can not be the soundid "Shrek", because it uses numbers and not stringers, ie names. Use:

local Shrek = Instance.new("Sound",script)
Shrek.Name = "Shrek"
Shrek.SoundId = "rbxassetid://2028376534"
local k = Shrek

script.Parent.MouseButton1Click:Connect(function()
    if k.Name == "Shrek" then
        print("Hey")
    end
end)

else

script.Parent.Enter.MouseButton1Click:Connect(function()
    if k.SoundId ==  "rbxassetid://".."Shrek" then
        k.SoundId = "rbxassetid://".."Shrek"
    end
end)

New:

for _,k in pairs(script:GetChildren()) do

if k:IsA("Sound")then

script.Parent.MouseButton1Click:Connect(function()
    if k.Name == "Shrek" then
        k.SoundId = "rbxassetid://".."2028376534" -- shrek national anthem
        k.Playing = true
    end
end)
script.Parent.MouseButton1Click:Connect(function()
    if k.Name == "Sans" then
        k.SoundId = "rbxassetid://".."2525122648" -- sans default dance
        k.Playing = true
    end
end)
script.Parent.MouseButton1Click:Connect(function()
    if k.Name == "AW MAN" then
        k.SoundId = "rbxassetid://".."1057637788" -- creepa, AW MAN. SO WE BACK IN THE MINE
        k.Playing = true
    end
end)
end
end
Ad

Answer this question