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

A little camera issue?

Asked by 9 years ago

So when a player joins my game they are spawned into a spawn box but there camera views the chosen area I selected (Which is good!) Now when the player presses the join game button on the gui they are entered into the game and locked in first person mode. However I have a script that when the player dies they go to classic mode and the mouse is released so they can use the gui again. However this perticular part is not working. It works in studio but not in the actual game. Here is the code in starterpack.

local cam = workspace.CurrentCamera

local player = game.Players.LocalPlayer

player.Character.Humanoid.Died:connect(function(plr)
    cam.CameraType = "Scriptable"
    script.Parent.Parent.CameraMode = Enum.CameraMode.Classic
end)

This is supposed to release the camera. It works in studio but not in the actual game.

1 answer

Log in to vote
0
Answered by 9 years ago

I solved this issue turns out the players character was not loading. Here is what I came up with.

local player = script.Parent.Parent

repeat wait() until player.Character ~= nil

game.Players.LocalPlayer.Character.Humanoid.Died:connect(function()
    cam.CameraType = "Watch"
    script.Parent.Parent.CameraMode = Enum.CameraMode.Classic
end)
Ad

Answer this question