I am making a game and I’d like the player’s camera to look at a part. When the function StartGame() is called from a moduleScript, a RemoteEvent is fired to the client in the for loop. In the ClientEvent I’d like the player to look at the part specified in line 11. For some reason, all the other lines work but the look vector does nothing. I am calling the function StartGame() from the command bar as the server and then switching to the client.
Code that fires the RemoteEvent.
local enableCamera = game.ReplicatedStorage.RemoteEvents.enableCamera
for i,plr in pairs(plrs) do
local chair = setup["Chair" .. i]
plr.Character.HumanoidRootPart.CFrame = chair.Seat.Seat.CFrame
enableCamera:FireClient(plr, setup.LookPoint)
end
Player Local Script (Inside a Folder in StarterGui/PlayerGui) that listens for client events on the RemoteEvent “enableCamera”. “RemoteEvents” in ReplicatedStorage is just a Folder.
local enableCamera = game.ReplicatedStorage.RemoteEvents.enableCamera
enableCamera.OnClientEvent:Connect(function(lookat)
local plr = game.Players.LocalPlayer
plr.PlayerGui.MouseUnlock.Enabled = true
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
plr.CameraMode = Enum.CameraMode.LockFirstPerson
workspace.CurrentCamera.CFrame = CFrame.new(workspace.CurrentCamera.CFrame.Position, lookat.Position)
end)
There are no errors to any of the scripts.
Command I am using in the Command Bar to call the function StartGame()
local gameAPI = require(game.ServerScriptService.gameAPI)
gameAPI.StartGame({game.Players.happyfloppy6}, workspace.Setup)