#How do I Make a disableEffect function that reverts the camera back to normal from the top down view

1 messages · Page 1 of 1 (latest)

viscid bobcat
#
local plr = game.Players.LocalPlayer
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")

local cam = workspace.CurrentCamera

local runService = game:GetService("RunService")

local gameInSession = game:GetService("ReplicatedStorage"):WaitForChild("gameInSession")

local yAmnt = 30

local function enableEffect()
    cam.CameraType = Enum.CameraType.Scriptable
    
    
    runService.RenderStepped:Connect(function()
        cam.CFrame = CFrame.new(hrp.Position + hrp.CFrame.UpVector * yAmnt) * CFrame.Angles(math.rad(-90),0,math.rad(90))
    end)
end

local function disableEffect()

    end)
end

hum:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
hum.JumpPower = 0
hum.JumpHeight = 0

enableEffect()
wait(3)
disableEffect()
umbral forum
#

in disable effect just set the camera type to custom and the subject back to the humanoid root part

viscid bobcat
#

@umbral forum the camera ramains stuck in the air, I cant zoom or move it, the only thing i can do is shift lock

#
local function disableEffect()
    cam.CameraType = Enum.CameraType.Custom

        cam.CFrame = hrp.CFrame
end
umbral forum
#
local function disableEffect()
    cam.CameraType = Enum.CameraType.Custom

    cam.CameraSubject = hrp
end
viscid bobcat
#

@umbral forum

teal crystalBOT
#

studio** You are now Level 3! **studio

umbral forum
# viscid bobcat same issue as here

Try disconnecting the Runservice event when you disable the event or store a variable and only run the runservice code if the camera effect is on

echo root
#

the RenderStepped connection is never disconnected so it keeps overwriting the CFrame every frame even after you set it back. store the connection and disconnect it in disableEffect and it's hum not hrp for CameraSubject: ```lua
local connection

local function enableEffect()
cam.CameraType = Enum.CameraType.Scriptable
connection = runService.RenderStepped:Connect(function()
cam.CFrame = CFrame.new(hrp.Position + hrp.CFrame.UpVector * yAmnt) * CFrame.Angles(math.rad(-90), 0, math.rad(90))
end)
end

local function disableEffect()
if connection then
connection:Disconnect()
connection = nil
end
cam.CameraType = Enum.CameraType.Custom
cam.CameraSubject = hum
end```