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

How to fix a camera on a part of a face ?

Asked by 5 years ago

I want to make a 2 player 2D style game with a Surface Gui and Camera fixing for each player but im bad at camera manipulation i gave a try but it did not work :

local function LookAtFace(part, face, distance)
    face = face or Enum.NormalId.Front
    distance = distance or 10

    if (type(face) == "string") then
        face = Enum.NormalId[face] 
    end

    local position = part.Position
    local offset = part.CFrame:vectorToWorldSpace(Vector3.FromNormalId(face)) -- Gets the Vector3 from the face you put in and rotate it to world space

    workspace.CurrentCamera.CoordinateFrame = CFrame.new(position + distance*offset, position)
end

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable

LookAtFace(game.Workspace.GameGUI, "Front", 20) 

i put this script in workspace maybe its the problem

0
You shouldn't put this in workspace because it has current camera in it and that has to be from a player  OBenjOne 190 — 5y
0
i tried everywhere fego2015 0 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

I just put it in ReplicatedFirst and it worked

Ad

Answer this question