Hi, I’m trying to get players to have ambience/music in the background playing based on which team they’re on without the audio itself resetting. For some reason despite every other piece of code properly working, the moment I put in a line to detect which team the player is on the script broke without giving an error.
You used if player.Team == "Undecided" then, try using if team == game.Teams.Undecided then.
Here is an example of how you could use this:
local UndecidedAmbience = game.Workspace.SoundFx.UndecidedAmbience
local Team1Ambience = game.Workspace.SoundFx.Team1Ambience
local Team2Ambience = game.Workspace.SoundFx.Team2Ambience
local player = game.Players.LocalPlayer
local team = player.Team
if team == game.Teams.Undecided then
UndecidedAmbience:Play()
elseif team == game.Teams.Team1 then
Team1Ambience:Play()
elseif team == game.Teams.Team2 then
Team2Ambience:Play()
end
Also, make sure everything is spelt right.
Here are pictures of what my explorer looks like:
Note: if you don’t have a “undecided” team, but want players to hear the UndecidedAmbience if they have not selected a team yet, just change the following:
if team == game.Teams.Undecided then
UndecidedAmbience:Play()
elseif team == game.Teams.Team1 then
Team1Ambience:Play()
elseif team == game.Teams.Team2 then
Team2Ambience:Play()
end
to
if team == game.Teams.Team1 then
Team1Ambience:Play()
elseif team == game.Teams.Team2 then
Team2Ambience:Play()
else
UndecidedAmbience:Play()
end