So I have dummy1 and dummy2
"Campart1" part is facing "dummy1" "Campart2" part is facing "dummy2"
I need the script to get to where that if I am on team (Bright red) I would have the view of "Campart1" facing the dummy1
Then if I was on (Bright blue) Then it would be the view of "Campart2" facing the dummy2
This script works but not with the team thing , I automatically have the view of "CamPart1" facing dummy1
local cam = game.Workspace.CurrentCamera cam.CameraType = Enum.CameraType.Scriptable cam.CameraSubject = game.Workspace:WaitForChild('CamPart1') cam.CFrame = CFrame.new(game.Workspace:WaitForChild('CamPart1').Position + Vector3.new(0,0,0))
I put the localscript in StarterGui
I tried doing this
game.Players.PlayerAdded:connect(function(plr) if plr.TeamColor == BrickColor.new("Bright red") then local cam = game.Workspace.CurrentCamera cam.CameraType = Enum.CameraType.Scriptable cam.CameraSubject = game.Workspace:WaitForChild('CamPart1') cam.CFrame = CFrame.new(game.Workspace:WaitForChild('CamPart1').Position + Vector3.new(0,0,0)) end)
I also tried doing this but still does not work
for i,v in pairs(game.Players:GetChildren())do if v.TeamColor == BrickColor.new("Bright red") then print(v.Name.." is on the Bright red team!") local cam = game.Workspace.CurrentCamera cam.CameraType = Enum.CameraType.Scriptable cam.CameraSubject = game.Workspace:WaitForChild('CamPart1') cam.CFrame = CFrame.new(game.Workspace:WaitForChild('CamPart1').Position + Vector3.new(0,0,0)) elseif v.TeamColor == BrickColor.new("Bright blue") then print(v.Name.." is on the Bright blue team!") local cam = game.Workspace.CurrentCamera cam.CameraType = Enum.CameraType.Scriptable cam.CameraSubject = game.Workspace:WaitForChild('CamPart2') cam.CFrame = CFrame.new(game.Workspace:WaitForChild('CamPart2').Position + Vector3.new(0,0,0)) end end
The simple answer would be using a for
loop, and checking what team each player is on.
Example:
for i,v in pairs(game.Players:GetChildren())do if v.TeamColor == BrickColor.new("Bright red") then print(v.Name.." is on the Bright red team!") elseif v.TeamColor == BrickColor.new("Bright blue") then print(v.Name.." is on the Bright blue team!") end end