Why does this code cause the player to float with streaming enabled on but not with is off?

I’m trying to fix the following code so that it works with streaming enabled on:

function WallStick:OnStep(dt)
	self.HRP.Velocity = ZERO
	self.HRP.RotVelocity = ZERO
	
	local hrpOffset = self.PhysicsFloor.CFrame:ToObjectSpace(self.PhysicsHRP.CFrame)
	self.HRP.CFrame = self.Part.CFrame:ToWorldSpace(hrpOffset)
	--this next part is not the issue
	local newPart, newNormal = self:GetFloorAndNormal(self.Part, self.Normal, self.LastTick)
	if (newPart and newNormal) then
		self:Set(newPart, newNormal)
	elseif (not self.Part.Parent) then
		self:Set(TERRAIN, UNIT_Y)
	end
	-- server replication
	self.OtherFrame = not self.OtherFrame
	if (self.OtherFrame) then
		local hrpOffset = self.PhysicsFloor.CFrame:ToObjectSpace(self.PhysicsHRP.CFrame)
		PhysicsReplicationEvent:FireServer(self.Part, hrpOffset, false)
	end
	
	self.PhysicsHumanoid.WalkSpeed = self.Humanoid.WalkSpeed
	self.PhysicsHumanoid.JumpPower = self.Humanoid.JumpPower
	self.PhysicsHumanoid.Jump = self.Humanoid.Jump
	
	-- camera
	if (self.CameraMode == "Custom") then
		self.CameraUp = self.Part.CFrame:VectorToWorldSpace(self.Normal)
	end

	-- mouse lock
	local pHRPCF = self.PhysicsHRP.CFrame
	local pCamCF = pHRPCF * self.HRP.CFrame:ToObjectSpace(workspace.CurrentCamera.CFrame)

	self.Gyro.CFrame = CFrame.new(pHRPCF.p, pHRPCF.p + pCamCF.LookVector * VEC_XZ)
	self.Gyro.Parent = self.Camera:IsCamRelative() and self.PhysicsHRP or nil
end
1 Like