Hello Im trying to make a script for my sub game. The idea is that there should be a sound between two height limits. Like in shallow water there is one sound and when in deeper there is another sound. Only the player whos in that hight limit should hear that sound and others who arent shouldnt. The sound should also loop as long as the player is in that area and should stop if the player left the area. So is it possible to make this script? If someone could help me with this I would be really grateful.
The way I would do it would be the camera position, and if the y coordinate is below a certain point then it will switch the sound.
Heres an example:
-- Local Script cam = game.Workspace.CurrentCamera minheight = 5 -- height (in studs) before it plays the deep sound sound = script.Parent.Sound -- location of the sound (put it somewhere on the client like StarterGui) deepsound = "" -- the sound of when the sub is deep shallowsound = "" -- the sound of when the sub is in shallow sound.Looped = true while true do if cam.CoordinateFrame.Position.Y <= minheight then sound:Stop() sound.SoundId = deepsound sound:Play() else sound:Stop() sound.SoundId = shallowsound sound:Play() end end