I have been trying to get a system to detect player teams on the client so I can play music while the game is running or if you are waiting in the lobby. But I have tried doing it over and over again with no result. Can anyone give me a hand?
local script
local ReplicatedStorage = game.ReplicatedStorage
local Music = script.Parent.Music
local result = ReplicatedStorage.TeamCheck:InvokeServer()
local id = {"Placeholder", "Placeholder", "Placeholder"} -- these are placeholders to prevent stealing
print(result)
while true do
wait(0.5)
if result == 1 then
Music:play()
Music.SoundId = "rbxassetid://"..id[1]
else
if result == 2 then
Music.Playing = true
Music.SoundId = "rbxassetid://"..id[2]
else
Music.Playing = true
Music.SoundId = "rbxassetid://"..id[3]
end
end
end
server script
game.ReplicatedStorage.TeamCheck.OnServerInvoke = function(player)
if player.TeamColor == BrickColor("Pearl") then
print("1")
return 1
else
if player.TeamColor == BrickColor("Really red") then
print("2")
return 2
end
end
end

9 comments
ok this just makes me lost.
Lost? Explain.
all you did was give me 4 lines of code without saying anything I would at lease like one peace of advice to tell me what I did wrong like "you miss spelled a word on line 11" or tell me what to add or remove. But just giving me code with no context is not gonna help. Even just saying things about it without giving me code can help too. Sorry if I appear rude just want to let you know.
update: I see that you updated your answer I will look at it and I will approve it. if it works.
You're right, but see if my edit works. Player.Team is an Object not a string as everyone expects. You also keep your script much clearer if you don't use brickcolor but strings.
For example, you also did Brickcolor("Pearl") with your local script on line 6. This doesn't work, it should be BrickColor.new("Pearl").
(The comments may be a bit mixed up I think the site is a bit slow)
true
Welp, It didn't work