hello developers, I have a problem with a localscript, I’m looking for a solution, I explain when I touch a part my camera switches to 2D camera for example it’s in first person and touching a part puts it in 2d camera
the problem is that when the player dies having the 2d camera activated, that is, I activate it from another localscript, it bugs because the script is restarted and disabled, how can I make the script remain enabled at the time of death, also being in 2d
The scripts would have to not be in the character or you would have to make it re-initialize upon spawn. Also, are your circles and arrows ok?? do they need to see a doctor?
local RunService = game:GetService('RunService')
local Plr = game:GetService('Players').LocalPlayer
local Camera = workspace.CurrentCamera
local is2D = false
Plr.CharacterAdded:Connect(function(Char)
RunService:UnbindFromRenderStep(Plr.UserId)
local rootPart:BasePart = Char:WaitForChild('HumanoidRootPart')
local function UpdateCamera()
if is2D then
local Goal = CFrame.lookAt(
rootPart.Position + Vector3.new(0, 15, 50),rootPart.Position -- Look from the rootPart position plus (0,15,0) towards the rootPart position
)
Camera.CFrame = Camera.CFrame:Lerp(Goal,.3) -- Lerp the camera CFrame
Camera.CameraType = Enum.CameraType.Scriptable
else
Camera.CameraType = Enum.CameraType.Custom
end
end
RunService:BindToRenderStep(Plr.UserId,1,UpdateCamera)
end)
workspace.Part.ProximityPrompt.Triggered:Connect(function(p)
if p == Plr then is2D = not is2D end -- Toggle 2D variable
end)
Place this in a LocalScript inside StarterPlayerScripts.