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

How to add sound into cloned object, adjust volume then play it?

Asked by
KWEEBO 2
3 years ago
Edited 3 years ago

I been trying to add a sound into a cloned object and then play it. Though I've not sure what I've been doing wrong since there's no error in Dev Console or Output.

local sword=game.ReplicatedStorage.sword1v:Clone()
local sound = Instance.new("Sound")
local soundid = "3031372793"
local sp = sword.sound
sp.SoundId = soundid
sp.Volume = 3
sp:Play()
  1. After adding rbxassetid://, I now received an error on my output.

sound is not a valid member of MeshPart "sword1v"

1 answer

Log in to vote
0
Answered by
3F1VE 257 Moderation Voter
3 years ago
Edited 3 years ago

You forgot to add "rbxassetid://" to the start of soundid

local sword=game.ReplicatedStorage.sword1v:Clone()
sword.Parent = workspace -- set this to whatever it was intentionally supposed to be
local sound = Instance.new("Sound")
sound.Parent = sword
local soundid = "rbxassetid://3031372793" -- If you want to play a sound from the roblox website put "rbxassetid://" before the id.
sound.SoundId = soundid
sound.Volume = 3
sound:Play()
0
I will remember that, but now I have another error saying: sound is not a valid member of MeshPart "sword1v". any idea? KWEEBO 2 — 3y
0
You forgot to parent sound. 3F1VE 257 — 3y
0
Also you can just use sound instead of sp 3F1VE 257 — 3y
0
I see, thank you KWEEBO 2 — 3y
Ad

Answer this question