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

Camera CFrame change event in the script not working?

Asked by
sebanuevo 123
4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago

You can't use

workspace.CurrentCamera

in a server script.

0
Its a local script sebanuevo 123 — 4y
0
Well then, you can't use game.Players.PlayerAdded in a local script. deeskaalstickman649 475 — 4y
Ad
Log in to vote
0
Answered by
sebanuevo 123
4 years ago

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)

Answer this question