Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local SoundPlayer = require(script.SoundPlayer)
- local rng = Random.new()
- while not script.Sounds.Value do wait() end
- while not script.Part.Value do wait() end
- function PositionWithin(part: Part?) : Vector3?
- if not part then return nil end
- local halfSize = part.Size / 2
- local offset = Vector3.new(
- rng:NextNumber(-halfSize.X, halfSize.X),
- rng:NextNumber(-halfSize.Y, halfSize.Y),
- rng:NextNumber(-halfSize.Z, halfSize.Z)
- )
- return part.CFrame:PointToWorldSpace(offset)
- end
- while true do
- local playbackInterval = script:GetAttribute("PlaybackInterval")
- wait(rng:NextNumber(playbackInterval.Min, playbackInterval.Max))
- local isVolumetric = script:GetAttribute("IsVolumetric") or false
- local Sounds = script.Sounds.Value
- local Part = script.Part.Value
- local from = if isVolumetric then Part else PositionWithin(Part)
- if script:GetAttribute("VisualizeEmitters") then
- SoundPlayer.PlayWithVisuals(Sounds, from)
- else
- SoundPlayer.Play(Sounds, from)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment