Trying to make a team overhead gui with flag indicators (for now I’m using a textlabel as an easier cover-up)
Issue is that even though the team change to either ‘PAVN’ or ‘ARVN’ is executed within the client, but server still sees the player as part of ‘SPECTATOR’ so the label on the overhead BillboardGui remains unchanged - only when I switch to Server view and manually put myself into one of the teams does the label change.
visualized issue
client view, registers
server view, doesn’t register
after manual server adjustment
Basically speaking, I want to make sure that the label also changes to the corresponding team name when the player picks their allegiance, recorded and executed on both client AND server (autochange). How do I fix this? Do I have to merge scripts with ‘MenuAccuScript’ ?
-- local script, within StarterPlayerScripts
-- called 'localteamch'
local repfirst = game:GetService('ReplicatedFirst')
local repStorage = game:GetService('ReplicatedStorage')
local players = game:GetService('Players')
local teams = game:GetService('Teams')
local PAVN = teams:WaitForChild('PAVN')
local ARVN = teams:WaitForChild('ARVN')
local SPECTATOR = teams:WaitForChild('SPECTATOR')
local AllegianceChanged = repfirst:WaitForChild('AllegianceChanged')
local plr = players.LocalPlayer
local menu2gui = repfirst.LoadingSequence:WaitForChild('Menu2Gui')
menu2gui.ResetOnSpawn = false
menu2gui.Parent = plr:WaitForChild("PlayerGui")
local function showPicker()
if plr.Team == SPECTATOR then
menu2gui.Enabled = true
else
menu2gui.Enabled = false
end
end
showPicker()
plr:GetPropertyChangedSignal('Team'):Connect(showPicker)
local SVNButton = menu2gui.backingfr.SouthVietN
local NVNButton = menu2gui.backingfr.NorthVietN
SVNButton.MouseButton1Click:Connect(function()
AllegianceChanged:FireServer(ARVN)
end)
NVNButton.MouseButton1Click:Connect(function()
AllegianceChanged:FireServer(PAVN)
end)
-- regular script, within ServerScriptService
-- called 'TeamChanger'
local repStorage = game:GetService('ReplicatedStorage')
local players = game:GetService('Players')
local teams = game:GetService('Teams')
local PAVN = teams:WaitForChild('PAVN')
local ARVN = teams:WaitForChild('ARVN')
local SPECTATOR = teams:WaitForChild('SPECTATOR')
local chooseEvent = repStorage:WaitForChild('AllegianceChanged')
local function onEvent(playerFrom, teamChosen)
if teamChosen == PAVN then
playerFrom.Team = PAVN
elseif teamChosen == ARVN then
playerFrom.Team = ARVN
else
playerFrom.Team = SPECTATOR
if playerFrom.Character then
playerFrom.Character:Destroy()
end
return
end
playerFrom:LoadCharacter()
end
chooseEvent.OnServerEvent:Connect(onEvent)
-- within ReplicatedFirst, directly parented to LoadingSequence -> Menu2Gui (main menu ScreenGui), called MenuAccuScript
local MenuGui = script.Parent
local Player = MenuGui.Parent.Parent
MenuGui.Enabled = true
script.Parent.backingfr.NorthVietN.MouseButton1Click:Connect(function()
Player.Team = game.Teams.PAVN
script.Parent.backingfr.NorthVietN["Cartoon bubble button Sound"]:Play()
local character = workspace:FindFirstChild(Player.Name)
character.Humanoid.Health = 0
MenuGui.Enabled = false
end)
script.Parent.backingfr.SouthVietN.MouseButton1Click:Connect(function()
Player.Team = game.Teams.ARVN
script.Parent.backingfr.SouthVietN["Cartoon bubble button Sound"]:Play()
local character = workspace:FindFirstChild(Player.Name)
character.Humanoid.Health = 0
MenuGui.Enabled = false
end)
-- almost forgot about this one, this script is for the overhead gui itself in ServerScriptService
-- named 'teamindicatorrig'
local TeamIndicator = game.ReplicatedStorage:WaitForChild("TeamIndicator")
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(character)
local TeamIndicatorClone = TeamIndicator:Clone()
TeamIndicatorClone.Parent = plr.Character.Head
TeamIndicatorClone.TextLabel.Text = plr.Team.Name
end)
plr.Changed:Connect(function()
game.Workspace:WaitForChild(plr.Name)
if plr.Character.Head:FindFirstChild("TeamIndicator") then
plr.Character.Head.TeamIndicator.TeamLabel.Text = plr.Team.Name
else
local TeamIndicatorClone = TeamIndicator:Clone()
TeamIndicatorClone.Parent = plr.Character.Head
TeamIndicatorClone.TextLabel.Text = plr.Team.Name
end
end)
end)
please help.
for those who need the explorer hierarchy







