I’m making a simple module for my game called StillSound, where I can give the module a Sound instance and a Vector3 position and it will play a sound at that position. For some reason, the sound doesn’t play. Here is my code:
local StillSound = {}
function StillSound:Play(sound, position)
local stillSound = Instance.new("Part")
sound:Clone().Parent = stillSound
stillSound.Transparency = .5
stillSound.Anchored = true
stillSound.CanCollide = false
stillSound.CanQuery = false
stillSound.CanTouch = false
stillSound.Position = position
stillSound.Name = "StillSound"
stillSound.Parent = workspace
sound:Play()
task.spawn(function()
sound.Ended:Wait()
if stillSound then
stillSound:Destroy()
end
end)
end
return StillSound
And what happens in game:
You can see it doesn’t play or does play for a split second before stopping. It should play a sword damage sound. How can I fix this?
Any help is appreciated.