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

Camera CFrame change event in the script not working?

This event in the script its supposed to change the cframe of the current camera if the player is on a team but it doesn't work

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function()
		if plr.TeamColor == BrickColor.new("Maroon") then
			camera.CFrame = workspace.cameraimplicado.CFrame
		end
	end)
end)

Full script:

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
repeat wait()
camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
camera.CFrame = workspace.camerajuez.CFrame
camera.FieldOfView = 60

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function()
		if plr.TeamColor == BrickColor.new("Maroon") then
			camera.CFrame = workspace.cameraimplicado.CFrame
		end
	end)
end)


2 answers

✓ Accepted answer

You can't use

workspace.CurrentCamera

in a server script.

2 comments

0

Its a local script

0

Well then, you can't use game.Players.PlayerAdded in a local script.

Oops my bad i had to remove the player added and put local player, Solved

Fixed local script:

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
repeat wait()
camera.CameraType = Enum.CameraType.Scriptable
until camera.CameraType == Enum.CameraType.Scriptable
camera.CFrame = workspace.camerajuez.CFrame
camera.FieldOfView = 60


player.Chatted:Connect(function()
		if player.TeamColor == BrickColor.new("Maroon") then
			camera.CFrame = workspace.cameraimplicado.CFrame
		end
	end)

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