The module contains the following code (print statement added by me):
local subjectRoot
local subjectPart
camera:GetPropertyChangedSignal("CameraSubject"):Connect(function()
local subject = camera.CameraSubject
if subject:IsA("Humanoid") then
subjectPart = subject.RootPart
print("added", subject, subjectPart)
elseif subject:IsA("BasePart") then
subjectPart = subject
else
subjectPart = nil
end
end)
Output when playing the game, demonstrating the bug:
added Humanoid nil
What this means is that Humanoid.RootPart may not be set on the Humanoid when the value of CameraSubject changes. Therefore subjectPart
never gets set to a valid root part even if it gets added later.
The correct behavior would be have to a changed signal on the humanoid so subjectPart
gets updated correctly when the root part changes.
Also, I don’t believe any of this works with StreamingEnabled, though it’s unlikely the local character will get streamed out.
5 Likes
Thanks for the report! I filed a ticket in our internal database.
1 Like
Bumping this because it’s still a problem. Here’s the fix I use in my forked copy of the PlayerModule (indicated by @Modification:On
blocks):
cameraWrapper:Connect("CameraSubject", function()
local subject = cameraWrapper:getCamera().CameraSubject
if subject:IsA("Humanoid") then
---[[ @Modification:On RootPartBug
subjectPart = subject
--]]
--[[ @Modification:Off RootPartBug
subjectPart = subject.RootPart
--]]
elseif subject:IsA("BasePart") then
subjectPart = subject
else
subjectPart = nil
end
end)
local function Popper(focus, targetDist, focusExtrapolation)
debug.profilebegin("popper")
---[[ @Modification:On RootPartBug
local ActualSubjectPart = nil
if subjectPart then
if not subjectPart:IsA("Humanoid") then
ActualSubjectPart = subjectPart
else
ActualSubjectPart = subjectPart.RootPart
end
end
if ActualSubjectPart then
subjectRoot = ActualSubjectPart:GetRootPart() or ActualSubjectPart
end
--]]
--[[ @Modification:Off RootPartBug
subjectRoot = subjectPart and subjectPart:GetRootPart() or subjectPart
--]]
local dist = targetDist
local soft, hard = queryViewport(focus, targetDist)
if hard < dist then
dist = hard
end
if soft < dist and testPromotion(focus, targetDist, focusExtrapolation) then
dist = soft
end
subjectRoot = nil
debug.profileend()
return dist
end