I have a code that toggles the spectate button, and when the team changes it goes away successfully, but on the teams changing again it doesnt come back. any ideas?
player:WaitForChild("SelectedTeam"):GetPropertyChangedSignal("Value"):Connect(function(Value)
local Con
Con = runService.Heartbeat:Connect(function()
if Value == "King" or "Bodyguards" or "Assassins" then
isAllowed = false
script.Parent.Frame.Visible = false
end
end)
end)
Ps, the teams that should be able to see it are Lobby and Dead
If i put something like this after it:
player:WaitForChild("SelectedTeam"):GetPropertyChangedSignal("Value"):Connect(function(Value)
local Con
Con = runService.Heartbeat:Connect(function()
if Value == "Lobby" or "Dead" then
isAllowed = true
script.Parent.Frame.Visible = true
end
end)
end)
The original one stops working (and the button still is visible while they are king ,assassin and bodyguard)
So do you like want it so when someone dies it opens on the spectate button? LIke is that how ur game work?
Yeah when they are dead they get the Selectedteam Value of dead, so i would like them to spectate. Also, when everyone goes back to the Lobby they get the ‘Lobby’ value, so id like it to reappear
Surely you could just change the spectate UI visible when you change there team when the player dies? Or in the terms of the end of the game then do the exact same just in the script where it ends the game and changes there team.
Is that not what the second bit of code I added above should do?
In your script to me it looks like you are waiting for a change of the player team cuz i dont see when u change the player team to the lobby/dead.
Why would it not work the SelectedTeam.Value way? (the values do change back btw as expected just the button doesnt go visible with it)
Um I am not sure, It is strange on how it does change the sectedteam value but not the UI. It is the correct path to the UI right u put? (the script.Parent.Frame)
Yeah because it dissapears as expected
So the isAllowed changes to true? Also what is this selectedteam?
Selectedteam is a string value within the player, and goes to false when it dissapears, meant to go back to true when in lobby/dead
In the second script u change the isAllowed though not the Selectedteam?
Not sure what you mean but this is what i expect to work:
player:WaitForChild("SelectedTeam"):GetPropertyChangedSignal("Value"):Connect(function(Value)
local Con
Con = runService.Heartbeat:Connect(function()
if Value == "King" or "Bodyguards" or "Assassins" then
isAllowed = false
script.Parent.Frame.Visible = false
end
end)
end)
player:WaitForChild("SelectedTeam"):GetPropertyChangedSignal("Value"):Connect(function(Value)
local Con
Con = runService.Heartbeat:Connect(function()
if Value == "Lobby" or "Dead" then
isAllowed = true
script.Parent.Frame.Visible = true
end
end)
end)
Without looking into your problem too much, I should warn you that this doesn’t work.
This expression is evaluated like this in Lua.
if (Value == "Lobby") or ("Dead" ~= nil) then
And obviously Dead~=nil, so this condition will always pass. Change it to this.
if Value == "Lobby" or Value == "Dead" then
and same with the line above, and any other instances like this.
if Value == "King" or Value == "Bodyguards" or Value == "Assassins" then
Oh thats interesting. Why is that? and il implement this now thanks 
Oh hold on hahah just completely misunderstood what you meant. Bet that made you laugh, misinterpreted ‘evaluated’ there. il give it a go now
Ok this would be a more accurate depiction of what im trying to do
player:WaitForChild("SelectedTeam"):GetPropertyChangedSignal("Value"):Connect(function(Value)
local Con
Con = runService.Heartbeat:Connect(function()
if Value == "King" or Value == "Assassins" or Value == "Bodyguards" then
isAllowed = false
script.Parent.Frame.Visible = false
else
isAllowed = true
script.Parent.Frame.Visible = true
if Con then
Con:Disconnect()
end
end
end)
end)
So, all of the SelectedTeams change ingame correctly, so do you have any clue why the button wont dissapear when changing value to king assassin, or bodyguard?
I removed the if con part because I believe that may be redundant (could be wrong)