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

I can't change the camera back to classic on death! Can someone help me?!

Asked by 6 years ago

I'm having trouble trying to change the camera back to Classic once you die. Can someone help me fix my script?

game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild('Humanoid').Died:connect(function()
            local player = game.Players.LocalPlayer
            player.CameraMode = "Classic"
        end)
    end)
end)
0
by the way, the camera mode is currently set on LockFirstPerson supercoolboy8804 114 — 6y
0
you can simply put a local script in StarterCharacterScripts to reset the camera on the players death. User#5423 17 — 6y
0
how would i do that? supercoolboy8804 114 — 6y

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
6 years ago
Edited 6 years ago

What You Need

FilteringEnabled is stipping you from doing what you want to do.. You're going to have to either setup a RemoteEvent to do this for you, or do everything on the client.


RemoteEvent Option

Place a RemoteEvent in ReplicatedStorage, use FireClient on the server, and OnClientEvent on the client. Do any camera manipulation on the client.


Script in ServerScriptStorage;

local death = game.ReplicatedStorage.Died --This is the RemoteEvent

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild('Humanoid').Died:connect(function()
            death:FireClient(player)
        end)
    end)
end)

LocalScript in StarterPack;

local player = game.Players.LocalPlayer
local re = game.ReplicatedStorage.Died

re.OnClientEvent:Connect(function()
    player.CameraMode = "Classic"
end)

Client-Sided Option

If you do everything on the client, there's no need to setup a RemoteEvent. Place a LocalScript in StarterPack;

local plr = game.Players.LocalPlayer

repeat wait() until plr.Character

local char = plr.Character
local hum = char:WaitForChild("Humanoid")

hum.Died:Connect(function()
    player.CameraMode = "Classic"
end)
Ad

Answer this question