Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Different Camera View for different team?

Asked by
Phixl 11
6 years ago
Edited 6 years ago

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


1 answer

Log in to vote
0
Answered by
obcdino 113
6 years ago

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
0
Do I put this localscript in startgui? Phixl 11 — 6y
0
I don't understand what you mean by that , could you connect the two scripts? Phixl 11 — 6y
Ad

Answer this question