Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Different Camera View for different team?

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

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

2 comments

0

Do I put this localscript in startgui?

0

I don't understand what you mean by that , could you connect the two scripts?

This discussion is preserved as it was. New answers, comments, and votes are closed.