Hey !
I’m making a spectating team, and I want that ONLY the spectating team can see a specific gui, here is the code :
local Player = game:GetService("Players")
local Team = game:GetService("Teams")
while true do
game.Players.PlayerAdded:Connect(function(player)
if player.Team == Team.Spectating then
script.Parent.Parent.Parent.Visible = true
end
end)
end
why is game.Players.PlayerAdded not game.Player.PlayerAdded?
1 Like
achdef
(TopicTop)
March 14, 2021, 9:24pm
#3
Hi! I see, your code is a little bit incorrect. Here would be a fix of it:
local Team = game:GetService("Teams")
local UI = script.Parent.Parent.Parent
game.Players.PlayerAdded:Connect(function(player)
if player.Team == Team["Spectating"] then
UI.Visible = true
end
end)
end
Don’t tell me that my mistake is that stupid…
achdef
(TopicTop)
March 14, 2021, 9:25pm
#5
That would not work. It’s would be Player.PlayerAdded, but I make it in my code above to fix it.
achdef
(TopicTop)
March 14, 2021, 9:26pm
#6
My code is the right one, @Black_Albi , you can test it if you want.
I’m animating something rn ^^
Thanks for you script, Imma save my anim and try it
no it’s not, it’s just you can do it like that, just you don’t need to call the player service, you already did in the playeradded.
Your code literally doesn’t do anything. Not only is script
mispelled as scrupt
, but also Team["Spectating"]
is the same as Team.Spectating
There is no need for the while loop.
achdef
(TopicTop)
March 14, 2021, 9:27pm
#10
Well. First, I removed the while, I fixed scrupt.
Black_Albi
(AlbiMousse)
March 14, 2021, 9:28pm
#11
scrupt is an error of copy cuz I had an image on my clip board and I didn’t want to lose it (I’m wondering why I didn’t paste it on paint…)
achdef
(TopicTop)
March 14, 2021, 9:37pm
#13
It is supposed to work. Can you show us the output so we can see the errors?
Black_Albi
(AlbiMousse)
March 14, 2021, 9:38pm
#14
Maybe make a while true do
– zdadzdad
this on a localscript? this is probably the issue.
Black_Albi
(AlbiMousse)
March 14, 2021, 9:41pm
#16
Yes it is
– DOn’t mind this –
alright i just got done with some stuff, let me review this, should take less than a few minutes unless i forget how to use teams.
i have somehow located the issue, im looking into it further.
“player.Team == Team.Spectating” shouldn’t be like this, it doesn’t print anything out so i’ll check on what i can do.
Black_Albi
(AlbiMousse)
March 14, 2021, 9:55pm
#19
Normally you can do Team[“Spectating”]
doesn’t work either, i’ve gotten off track but i am looking for other ways to pull this off.