The first time when it printed “Spectating” was when I Joined the game. The MaxZoomDistance was at 30 and the CanCollide part was false. Just as it should be.
The second time when it printed “Night Guard” was when I changed my team to Night Guard. The MaxZoomDistance went to 0.5 as it should be. The only thing was the CanCollide part was still false. The if statement is suppose to make the CanCollide part true if your team is “Night Guard.” How come it stays false?
You really only have to pay attention to the parts I circled and the explanation below the image, but I’ll show you the script in text form.
local players = game:GetService("Players")
local player = players.LocalPlayer
function onTeamChange(newTeam)
if newTeam == "Spectating" then
player.CameraMaxZoomDistance = 30
else
player.CameraMaxZoomDistance = 0.5 --0.5
end
print(newTeam)
if newTeam == "Night Guard" then
game.Workspace.Misc.InvisNG1.CanCollide = true
else
game.Workspace.Misc.InvisNG1.CanCollide = false
end
end
onTeamChange(player.Team)
player:GetPropertyChangedSignal("Team"):Connect(function()
onTeamChange(player.Team)
end)
I don’t understand why you posted that? You didn’t give any explanation for that and also I never put a team called “Night Guards.” I didn’t misspell it.
try doing newTeam == game.Teams["Night Guard"] and newTeam == game.Teams["Spectating"] because you are seeing if the team is equal to a string and not the actual team and the parameter you pass to the function is the players team not the team name OR do newTeam.Name == “Night Guard” and newTeam.Name == “Spectating”
the newTeam value is a string though. It printed out as a string, and it’s also able to compare the “Spectating” team just fine. Putting .Name on it won’t work and will return an error.