Hello developers, Today I was making camera manipulation that ends when boolvalue is unchecked. But whenever I tried to stop manipulation it just won’t stop. the script is below, if anyone knows please tell me.
if Chatting == true then
local Humanoid = detectedNPC:FindFirstChild("Humanoid")
local HMR = detectedNPC:FindFirstChild("HumanoidRootPart")
if Humanoid and HMR then
if Open.Value == false then
camera.CameraType = Enum.CameraType.Scriptable
TS:Create(camera, TweenInfo.new(1), {CFrame = HMR.CFrame * CFrame.new(0, 1.5, -4) * CFrame.Angles(0, math.pi, 0)}):Play()
Open.Value = true
end
else
if Open.Value == true then
camera.CameraType = Enum.CameraType.Custom
Open.Value = false
print("Value is false")
end
end
end
end)
I might be mistaken because I don’t understand much of camera manipulation, but the first thing I notice is that the only time this value will be put to false is when either the Humanoid or the HRM does not exist.
You have it like this:
if Humanoid and HMR then
-- stuff
else -- this will only ever happen if Humanoid or HMR does not exist
if Open.Value == true then
Open.Value = false
end
end
You say you’re new at scripting so I’ll try my best to help you out. But you’re saying that when you try to set the value to false it doesn’t work. That is because the value will only be false when there’s no Humanoid or HumanoidRootPart. I think this is an accident?
Can you let us know what exactly is supposed to happen to make this value false? Because now it only happens when you delete the humanoid.
Right now the camera changes to custom when it’s true and then the value becomes false
Is this the entire script or is there more at the top before “if Chatting == true then”?
if Humanoid and HMR then
if Open.Value == false then
camera.CameraType = Enum.CameraType.Scriptable
TS:Create(camera, TweenInfo.new(1), {CFrame = HMR.CFrame * CFrame.new(0, 1.5, -4) * CFrame.Angles(0, math.pi, 0)}):Play()
Open.Value = true
end
elseif Open.Value == true then
camera.CameraType = Enum.CameraType.Custom
Open.Value = false
print("Value is false")
end
end