Hi! I’ve been trying to determine wether a player can see a TextButton or not, depending on the Team they are currently assigned to. However, it doesn’t really work. Not sure what is causing it though, as it doesn’t outprint any errors, and it’s just a simple script.
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Teams = game:GetService("Teams")
local Gui = LocalPlayer.PlayerGui:WaitForChild("SpectateMenu")
local HolderFrame = Gui.Holder
local SpectateButton = HolderFrame.SpectateButton
LocalPlayer.CharacterAdded:Connect(function()
if LocalPlayer.Team == Teams.Dead or Teams.Spectators then
SpectateButton.Visible = true
elseif LocalPlayer.Team == Teams.Alive then
SpectateButton.Visible = false
end
end)
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Teams = game:GetService("Teams")
local Gui = LocalPlayer.PlayerGui:WaitForChild("SpectateMenu")
local HolderFrame = Gui.Holder
local SpectateButton = HolderFrame.SpectateButton
local function updateButton()
if LocalPlayer.Team == Teams.Dead or Teams.Spectators then
SpectateButton.Visible = true
elseif LocalPlayer.Team == Teams.Alive then
SpectateButton.Visible = false
end
end
updateButton()
LocalPlayer.CharacterAdded:Connect(updateButton)
LocalPlayer:GetPropertyChangedSignal('Team'):Connect(updateButton)
The error might be that the script thinks you’re asking if Teams.Spectators and not if player is spectators team.
Change the line with this:
your line:
if LocalPlayer.Team == Teams.Dead or Teams.Spectators then
corrected line:
if LocalPlayer.Team == Teams.Dead or LocalPlayer.Team == Teams.Spectators then
If this doesn’t work, it might be you defining the frames wrongly