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

A little camera issue help please?

Asked by 9 years ago

Okay so I'm working with a game and currently when the user joins in the game by pressing the join game button it sets there camera mode to firstpersonlock and when they die it sets it to Classic so there mouse can be released and thereforth they can click the button again. However after the first time the player dies it wont work anymore help?

Script (To set camera mode back):

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)

1 answer

Log in to vote
0
Answered by 9 years ago

Try this. The problem is that when the character dies, they get a new humanoid, so then you'll need their humanoid again to attach to the died event.

Make sure to put this into a LocalScript

local player = game.Players.LocalPlayer
local cam = game.Workspace.CurrentCamera

player.CharacterAdded:connect(function(chr)
    cam.CameraType = "Whatever It Should Be When They're Alive"
    cam.CameraMode = Enum.CameraMode.LockFirstPerson
    chr:WaitForChild("Humanoid").Died:wait()
    cam.CameraType = "Watch"
    script.Parent.Parent.CameraMode = Enum.CameraMode.Classic
end)
0
Little late to the punch but danke it works fine. I figured it out myself when I was working on the project but thanks! TacticalSutherland 20 — 8y
Ad

Answer this question