Okay so I've got a Folder in ServerStorage named Tags. Inside that Folder I've got two BillboardGuis, one named Blue Tag and the other named Red Tag.
Then I've got a round-based-game so each time the player's Team change, I want to clone the Gui and place in their character's Head. So to do that I've got two scripts, one LocalScript and one Server Script. The LocalScript is placed in StarterPlayer -> StarterPlayerScripts. The Server Script is located in ServerScriptService. I've got a RemoteEvent in ReplicatedStorage called PlayerTeam.
This is my code:
LocalScript
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local player = Players.LocalPlayer
local blueTeam = Teams:WaitForChild("Blue Team")
local redTeam = Teams:WaitForChild("Red Team")
local remEvent = game.ReplicatedStorage:WaitForChild("PlayerTeam")
player:GetPropertyChangedSignal("Team"):Connect(function()
if player.Team then
print("Team changed")
if not player.Team == blueTeam and not player.Team == redTeam then
return
elseif player.Team == blueTeam then
remEvent:FireServer("Blue Tag")
print("Blue Tag")
elseif player.Team == redTeam then
remEvent:FireServer("Red Tag")
print("Red Tag")
end
end
end)
Server Script
local remEvent = game.ReplicatedStorage:WaitForChild("PlayerTeam")
local ServerStorage = game.ServerStorage
remEvent.OnServerEvent:Connect(function(player, tag)
if player and player.Character and ServerStorage.Tags:FindFirstChild(tag) then
local redTag = player.Character:FindFirstChild("Red Tag")
local blueTag = player.Character:FindFirstChild("Blue Tag")
if redTag then
redTag:Destroy()
elseif blueTag then
blueTag:Destroy()
end
local clonedTag = ServerStorage.Tags:FindFirstChild(tag):Clone()
clonedTag.Parent = player.Character.Head
end
end)
Now the problem is that when a new player joins, they aren't in any Team, they are located in the Lobby. But my LocalScript believe they are so it Fires the RemoteEvent and prints Red Tag. Every time, it's Red Tag. And I just can't figure why. I've checked the Player Instance in the Explorer and the player isn't in any Team. I even typed in the command box print(player.Team) and it prints nil. On line 12 in the LocalScript I used to have this;
if player.Team and player.Team ~= nil then
or
if player.Team and not player.Team == nil then
but then it didn't work at all.
Any help would be appreciated! Thank you!

3 comments
Okay that makes no sense.. but it gave me an idea so I'll just try something real quick
Okay thank you. Sorry but your answer didn't really help. You just gave me an idea so I solved it myself. I'll accept this anyway
np