Download src/StarterPlayer/StarterCharacterScripts/SoundController.client.lua from algorembrant/TimberWoods: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/algorembrant/TimberWoods/resolve/main/src/StarterPlayer/StarterCharacterScripts/SoundController.client.lua
- Command line
-
hf download hf://algorembrant/TimberWoods/src/StarterPlayer/StarterCharacterScripts/SoundController.client.lua
-
curl -L -o SoundController.client.lua https://huggingface.co/algorembrant/TimberWoods/resolve/main/src/StarterPlayer/StarterCharacterScripts/SoundController.client.lua
1.03 kB
| -- src/StarterPlayer/StarterCharacterScripts/SoundController.client.lua | |
| local ReplicatedStorage = game:GetService("ReplicatedStorage") | |
| local SoundConfig = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("SoundConfig")) | |
| local SoundEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("SoundEvent") | |
| local function playSound(soundName, position) | |
| local soundId = SoundConfig[soundName] | |
| if not soundId then return end | |
| local sound = Instance.new("Sound") | |
| sound.SoundId = soundId | |
| sound.Volume = SoundConfig.SFXVolume or 1 | |
| sound.RollOffMaxDistance = 100 | |
| if position then | |
| local att = Instance.new("Attachment") | |
| att.WorldPosition = position | |
| att.Parent = workspace.Terrain | |
| sound.Parent = att | |
| sound:Play() | |
| sound.Ended:Once(function() att:Destroy() end) | |
| else | |
| sound.Parent = workspace | |
| sound:Play() | |
| sound.Ended:Once(function() sound:Destroy() end) | |
| end | |
| end | |
| SoundEvent.OnClientEvent:Connect(function(soundName, position) | |
| playSound(soundName, position) | |
| end) | |