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

(Going on another question) Sound Query (?)

Asked by 10 years ago

How I can make a sound file only be played in a certain distance and trail off, when the file's origin is a humanoid. The humanoid has clicked a key bound letter, and the audio is set off.

Currently the sounds are bound to J, K and L however they can be heard at the same volume across the whole map, these sounds should only play to a radius of 25 blocks, other tries and answers have only broken the current script:

local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() local sound = game.Workspace.Present local dbk = false local dbj = false local dbl = false local waitTime = 9 mouse.KeyDown:connect(function(key)

if key:lower() == "k" and dbk == false then dbk = true sound:Play() wait(waitTime) dbk = false end end)

local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() local sound = game.Workspace.Makeready mouse.KeyDown:connect(function(key) if key:lower() == "j" and dbj == false then dbj = true sound:Play() wait(waitTime)
dbj = false
end end)

local plr = game.Players.LocalPlayer local mouse = plr:GetMouse() local sound = game.Workspace.Fire mouse.KeyDown:connect(function(key) if key:lower() == "l" and dbl == false then dbl = true sound:Play() wait(waitTime) dbl = false
end end)

Answer this question