Ok so this script doesn’t play the sound when its put in a LocalScript as I want it to be client-side, I’m pretty much a beginner so is this because it needs to be modified and put in the player folders?
local Ambience = script.Parent
local triggerdistance = 10
local debounce = false
local sound = script.Parent.Sound
local function scare()
for _, player in ipairs(game.Players:GetPlayers()) do
if player.Character then
local distance = (Ambience.Position - player.Character.HumanoidRootPart.Position).magnitude
if distance <= triggerdistance then
return true
end
end
end
return false
end
while true do
if scare() and not debounce then
debounce = true
sound:Play()
task.wait(5)
debounce = false
end
task.wait(1)
end