for some reason when I die, the currentcamera does not update to the new character when it respawns.
This is the code that sets the currentcamera cframe to a part in the workspace.
You could bind the event when the character dies, the camera would return to its original type.
Something like this:
game.Players.LocalPlayer.CharacterAdded:Connect(function(character)
currentcam.CameraType=Enum.CameraType.Scriptable
currentcam.CFrame=maincam.CFrame
character.Humanoid.Died:Connect(function()
-- your code about the camera
end)
end)
Hey! First of all, make sure it’s not a server script. If you use CharacterAdded in a LocalScript, It wont detect your player joining because you character spawns before the localscript executes. I would either just fire a remoteEvent from the server to the client whenever the player joins/dies OR just remove the CharacterAdded function and add a wait() before changing the camera CFrame. The player’s camera won’t move, even when he dies.
Its a localscript. The characteradded event doesn’t work when I first join the game even though I added the wait() before it
Oh and by the way, I have another piece of code located in the same localscript that is supposed to fire when the player presses a button
button.MouseButton1Click:Connect(function()
currentcam.CameraType=Enum.CameraType.Custom
shopgui.Visible=false
closeevent:FireServer()
for i, v in pairs(script.Parent.Parent:GetChildren()) do
v.Visible=false
end
end)
I don’t recommend using CharacterAdded in a LocalScript.
It shouldn’t be a problem if you have more code in the local script, just do this:
-- Changing the camera CFrame to maincam
wait()
currentcam.CameraType = Enum.CameraType.Scriptable
currentcam.CFrame = maincam.CFrame
-- CODE
button.MouseButton1Click:Connect(function()
currentcam.CameraType=Enum.CameraType.Custom
shopgui.Visible=false
closeevent:FireServer()
for i, v in pairs(script.Parent.Parent:GetChildren()) do
v.Visible=false
end
end)