I know what I would (probably) use, but I don't know how I would piece it together in a script. The script is supposed to play music when the player gets within certain coordinates, and when they walk out the music stops.
I know I would use a Vector3
to get the position, but I don't know how you would make something happen between certain coordinates, and how you would put that in correlation with the other parts of the script. Below is a very general idea of how that would go.
if --Calculate the positions here then game.Workspace.Sound:Play() elseif game.Workspace.Sound:Stop()
As you can see, I'm very new to this and help would be very, very appreciated. Thank you in advance.
First you would use a Touched event if you wanted something to happen between specific coordinates, Or you could find how many Studs the Player is from a certain "Part" If you want the Player's position you can do that via
local Pos = player.Character.Torso.Position
Switch "Torso" to "UpperTorso" or another R15 Body part if R15 Enabled,
and if you wanted to do a touched event you would put a Part down in size it to what you want then put
Part.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Script end)
and if you wanted to find out the Studs between an Object and the Player you would have to do:
function GetInrange(part) return (part.Position - game.Players.LocalPlayer.Character.Torso.Position).magnitude >50 end
If you wanted a different position each time I would eliminate the Touched event and use something such as Studs then add your Sound, If I was not of any help please Comment or Rep me down.