how do I make a humanoid make some sound (using Sound) if any player gets close? For example a scream
Give each player a hitbox, then trigger the sound when someone comes into contact with that hitbox. To prevent spamming, you'll want a debounce in there too.
local scream = "rbxassetid://292124372" game:GetService("Players").PlayerAdded:Connect(function (p) p.CharacterAdded:Connect(function (c) local sound = Instance.new("Sound", c.Head) sound.SoundId = scream local hitbox = Instance.new("Part", c) hitbox.Size = Vector3.new(20, 20, 20) -- you might want to fiddle with this a bit hitbox.CanCollide = false hitbox.Transparency = 1 hitbox.Anchored = false local weld = Instance.new("Weld", c.HumanoidRootPart) weld.Part0 = c.HumanoidRootPart weld.Part1 = hitbox -- no need for C0 and C1 local db = true hitbox.Touched:Connect(function (h) if db and game:GetService("Players"):GetPlayerFromCharacter(h.Parent) then db = false sound:Play() wait(2) -- you also might want to change this db = true end end) end) end)