EVERYBODY STOP -1 ON ALL MY POSTS ITS STUPID AND VERY ANNOYING! I am trying to figure out if it's possible that if a player gets close to a part, a sound plays. But if the player goes away from the part, the sound doesnt play. Any help please?
We can find the magnitude (distance) between a character's position and the part using the property of Vector3s, magnitude.
local player = game.Players.LocalPlayer -- Must be a local script local part = game.Workspace.Part -- Part that makes the sound play local distance = 15 -- Studs away needed to make sound play local sound = game.SoundScape.Sound -- Sound you want to play while true do -- There are more efficient ways to check more than once, but this will work if (player.Character.Torso.Position - part.Position).magnitude <= distance and sound.IsPaused then sound:Play() elseif (player.Character.Torso.Position - part.Position).magnitude > distance and sound.IsPlaying then sound:Pause() end wait() end