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

How do i make a sound ambient? And part touch play sound?

Asked by 10 years ago

Would the ambient sound script be like this :

local sound = game.Workspace.Sound
sound:Play()
If huminoid 4 away then sound volume
value 0.1

I don't know if this is right, but i want the sound to get quieter as you walk away.

So basically i need to add a part where if the player walks farther away, the sound gets quieter until it's silent,

And also can i add a script where if a player touches a part it creates a sound.

If Hit(OnTouch)
Part
Then game.Workspace.Sound
sound:play()

1 answer

Log in to vote
1
Answered by
Hybric 271 Moderation Voter
10 years ago

** touch a part and play:**

function hit(p)
local h = p.Parent:findFirstChild("Humanoid")
if (h ~= nil) then
Workspace.Sound:Clone().Parent = script.Parent
script.Parent.Sound:Play()
end
end

script.Parent.Touched:connect(hit)

Thats all you need, when you walk away from a sound thats in a part it fades away.

0
I will am new to scripting, but i am good at building. Thank you for getting me ever so closer to knowing scripter, i'm still learning about functions and other terms but thank you for teaching me about sound. arjun9022 34 — 10y
Ad

Answer this question