Just a small question. Does Sound | Documentation - Roblox Creator Hub play the sound at the parents location at time of removal?
Just wondering if I can just use this property instead of creating a coroutine to play a sound once at a position then destroying it like here.
Current methods of playing sounds once at a location
-- Sound Util
-- Dthecoolest
-- March 12, 2021
local SoundUtil = {}
function SoundUtil.playSoundAtPosition(sound: Sound, position: Vector)
local soundPositionAttachment = Instance.new("Attachment")
soundPositionAttachment.WorldPosition = position
local sound = sound:Clone()
sound.Parent = soundPositionAttachment
soundPositionAttachment.Parent = workspace.Terrain
coroutine.wrap(function()
sound:Play()
sound.Ended:Wait()
sound:Destroy()
soundPositionAttachment:Destroy()
end)()
end
function SoundUtil.playSoundAtInstance(sound: Sound, workspaceInstance : Instance)
assert(workspaceInstance:IsA("BasePart") or workspaceInstance:IsA("Attachment"),"Must insert 3d instance")
local sound = sound:Clone()
sound.Parent = workspaceInstance
coroutine.wrap(function()
sound:Play()
sound.Ended:Wait()
sound:Destroy()
end)()
end
return SoundUtil