So i am making a spectator script where i have made it so if the player is in the lobby the InLobby value in there player is ticked and when you go into the map it unticks which works but i want me spectator script to display the players name if they are inside the map and hide it if they are in the lobby
Almost all of the code works the only bit i am struggling with is the InLobby.Changed:connect(function() which isn't working
This is a local script
this is the code i attempted:
local frame = script.Parent
local open = frame.Parent.Open
local close = frame.Parent.Close
local specLabel = frame.Parent.SpecLabel
local player = game.Players.LocalPlayer
local plr = game.Players:GetPlayers()
frame.Visible = false
close.Visible = false
specLabel.Visible = false
plr:FindFirstChild("InLobby").Changed:connect(function()
if plr:FindFirstChild("InLobby").Value == false then
if plr.Name ~= player.Name then
local name = Instance.new('TextButton')
name.Parent = frame
name.Text = plr.Name
name.TextScaled = true
end
end
end)
local function spec()
frame.Visible = not frame.Visible
for _, button in pairs(frame:GetChildren()) do
if button:IsA('TextButton') then
button:Destroy()
end
end
end
for _, plr in pairs(game.Players:GetChildren()) do
if plr:FindFirstChild("InLobby").Value == false then
if plr.Name ~= player.Name then
local name = Instance.new('TextButton')
name.Parent = frame
name.Text = plr.Name
name.TextScaled = true
name.MouseButton1Click:Connect(function()
local person = game.Players:FindFirstChild(name.Text)
if person:FindFirstChild("InLobby").Value == false then
game.Workspace.CurrentCamera.CameraSubject = person.Character
specLabel.Visible = true
specLabel.Text = 'Spectating '..name.Text
frame.Visible = false
close.Visible = true
else
game.Workspace.CurrentCamera.CameraSubject = player.Character
specLabel.Visible = false
close.Visible = false
end
end)
end
end
end
close.MouseButton1Click:Connect(function()
game.Workspace.CurrentCamera.CameraSubject = player.Character
specLabel.Visible = false
close.Visible = false
end)
open.MouseButton1Click:Connect(spec)

1 comment
i think u mean freecam right?